Fix for slowdown converting mesh to curve with large polygons
authorCampbell Barton <ideasman42@gmail.com>
Mon, 9 Jun 2014 15:18:05 +0000 (01:18 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 9 Jun 2014 15:18:05 +0000 (01:18 +1000)
Walk the linked list rather then doing index lookups.

source/blender/blenkernel/intern/mesh.c

index f0566a7f4738e5716892e84bf5f2e8cb9ad9888a..7197d560bcc7b0dadb15be7f0a2493fe1b10a1cc 100644 (file)
@@ -1531,7 +1531,7 @@ void BKE_mesh_from_nurbs(Object *ob)
 }
 
 typedef struct EdgeLink {
-       Link *next, *prev;
+       struct EdgeLink *next, *prev;
        void *edge;
 } EdgeLink;
 
@@ -1610,13 +1610,11 @@ void BKE_mesh_to_curve_nurblist(DerivedMesh *dm, ListBase *nurblist, const int e
                        BLI_freelinkN(&edges, edges.last);          totedges--;
 
                        while (ok) { /* while connected edges are found... */
+                               EdgeLink *edl = edges.last;
                                ok = false;
-                               i = totedges;
-                               while (i) {
-                                       EdgeLink *edl;
+                               while (edl) {
+                                       EdgeLink *edl_prev = edl->prev;
 
-                                       i -= 1;
-                                       edl = BLI_findlink(&edges, i);
                                        med = edl->edge;
 
                                        if (med->v1 == endVert) {
@@ -1643,6 +1641,8 @@ void BKE_mesh_to_curve_nurblist(DerivedMesh *dm, ListBase *nurblist, const int e
                                                BLI_freelinkN(&edges, edl);                 totedges--;
                                                ok = true;
                                        }
+
+                                       edl = edl_prev;
                                }
                        }