]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/export_mesh.py
Small optimization for mesh exporter performance
[libs/gl.git] / blender / io_mspgl / export_mesh.py
index 1652c1a494756eec3c772718b01897297046e444..541874b2bd2018c052d286962956a0a0a45f77b6 100644 (file)
@@ -64,6 +64,7 @@ class MeshExporter:
                        cache = VertexCache(self.cache_size)
 
                island = []
+               face_neighbors = []
                island_strips = []
                while 1:
                        if not island:
@@ -83,11 +84,13 @@ class MeshExporter:
                                        face = queue.pop(0)
                                        island.append(face)
 
-                                       for n in f.get_neighbors():
+                                       for n in face.get_neighbors():
                                                if not n.flag:
                                                        n.flag = True
                                                        queue.append(n)
 
+                               face_neighbors = [f.get_neighbors() for f in island]
+
                                # Unflag the island for the next phase
                                for f in island:
                                        f.flag = False
@@ -97,11 +100,11 @@ class MeshExporter:
                        # or along borders of a non-closed island.
                        best = 5
                        face = None
-                       for f in island:
+                       for i, f in enumerate(island):
                                if f.flag:
                                        continue
 
-                               score = sum(not n.flag for n in f.get_neighbors())
+                               score = sum(not n.flag for n in face_neighbors[i])
                                if score>0 and score<best:
                                        face = f
                                        best = score
@@ -195,7 +198,7 @@ class MeshExporter:
 
        def export(self, context, out_file, objs=None, progress=None):
                if objs:
-                       objs = [(o, mathutils.Matrix()) for i in objs]
+                       objs = [(o, mathutils.Matrix()) for o in objs]
 
                if self.compound:
                        if objs is None: