X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=blender%2Fio_mspgl%2Fmesh.py;h=f5665256b2eeced61c654abc329d4849e45d82cf;hb=9ab994ab4fedf938cbbdfe1ec1415e6c91844d21;hp=ac3f7c675605109266339bb4189571c7f54eaf2a;hpb=68488043ee491d117477a458f876e0d3f78e146e;p=libs%2Fgl.git diff --git a/blender/io_mspgl/mesh.py b/blender/io_mspgl/mesh.py index ac3f7c67..f5665256 100644 --- a/blender/io_mspgl/mesh.py +++ b/blender/io_mspgl/mesh.py @@ -83,7 +83,6 @@ class Face: self.normal = face.normal self.use_smooth = face.use_smooth self.material_index = face.material_index - self.uvs = [] self.flag = False def __cmp__(self, other): @@ -95,12 +94,8 @@ class Face: n = self.vertices.index(v) return [(n+i)%len(self.vertices) for i in range(len(self.vertices))] - def pivot_vertices(self, *vt): - flags = [(v in vt) for v in self.vertices] - l = len(self.vertices) - for i in range(l): - if flags[i] and not flags[(i+l-1)%l]: - return self.vertices[i:]+self.vertices[:i] + def get_loop_index(self, v): + return self.loop_indices[self.vertices.index(v)] def get_edge(self, v1, v2): key = make_edge_key(v1.index, v2.index) @@ -418,11 +413,6 @@ class Mesh: for i in f.loop_indices: l.uvs[i] = mathutils.Vector((*l.uvs[i], layer)) - # Copy UVs from layers to faces - for f in self.faces: - for u in self.uv_layers: - f.uvs.append([u.uvs[i] for i in f.loop_indices]) - prog_count = len(self.uv_layers) prog_step = 0 @@ -453,13 +443,13 @@ class Mesh: progress.pop_task() prog_step += 1 - # Copy UVs from faces to vertices + # Copy UVs from layers to vertices for v in self.vertices: if v.faces: # All faces still connected to the vertex have the same UV value f = v.faces[0] - i = f.vertices.index(v) - v.uvs = [u[i] for u in f.uvs] + i = f.get_loop_index(v) + v.uvs = [u.uvs[i] for u in self.uv_layers] else: v.uvs = [(0.0, 0.0)]*len(self.uv_layers) @@ -537,12 +527,13 @@ class Mesh: return group def find_uv_group(self, vertex, face, index): - uv = face.uvs[index][face.vertices.index(vertex)] + layer = self.uv_layers[index] + uv = layer.uvs[face.get_loop_index(vertex)] face.flag = True group = [face] for f in vertex.faces: - if not f.flag and f.uvs[index][f.vertices.index(vertex)]==uv: + if not f.flag and layer.uvs[f.get_loop_index(vertex)]==uv: f.flag = True group.append(f) @@ -552,9 +543,9 @@ class Mesh: for i, v in enumerate(self.vertices): v.normal = mathutils.Vector() for f in v.faces: - fv = f.pivot_vertices(v) - edge1 = fv[1].co-fv[0].co - edge2 = fv[-1].co-fv[0].co + vi = f.pivot_vertex(v) + edge1 = f.vertices[vi[1]].co-v.co + edge2 = f.vertices[vi[-1]].co-v.co if edge1.length and edge2.length: # Use the angle between edges as a weighting factor. This gives # more consistent normals on bends with an inequal number of