]> git.tdb.fi Git - libs/gl.git/commitdiff
Fix suspicious code in the mesh exporter
authorMikko Rasa <tdb@tdb.fi>
Sun, 21 Mar 2021 16:11:14 +0000 (18:11 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sun, 21 Mar 2021 16:11:14 +0000 (18:11 +0200)
The pivot_vertices function was expecting a list of vertices, but only
one vertex was passed in.  In fact the entire function seemed rather
useless now that the mesh is triangulated at an early stage.

blender/io_mspgl/mesh.py

index ac3f7c675605109266339bb4189571c7f54eaf2a..2296019e4cb3f45062b6bff14e3a147ec6c37c57 100644 (file)
@@ -95,13 +95,6 @@ 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_edge(self, v1, v2):
                key = make_edge_key(v1.index, v2.index)
                for e in self.edges:
@@ -552,9 +545,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