]> git.tdb.fi Git - libs/gl.git/commitdiff
Small optimization for mesh exporter performance
authorMikko Rasa <tdb@tdb.fi>
Sun, 10 Sep 2017 12:19:40 +0000 (15:19 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 10 Sep 2017 12:19:40 +0000 (15:19 +0300)
blender/io_mspgl/export_mesh.py

index c37d60ca8f7581e4df57b78483b7458465f7f8e5..541874b2bd2018c052d286962956a0a0a45f77b6 100644 (file)
@@ -64,6 +64,7 @@ class MeshExporter:
                        cache = VertexCache(self.cache_size)
 
                island = []
+               face_neighbors = []
                island_strips = []
                while 1:
                        if not island:
@@ -88,6 +89,8 @@ class MeshExporter:
                                                        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