fixed crash on loop cut of wire edge
authorHoward Trickey <howard.trickey@gmail.com>
Mon, 29 Aug 2011 14:13:14 +0000 (14:13 +0000)
committerHoward Trickey <howard.trickey@gmail.com>
Mon, 29 Aug 2011 14:13:14 +0000 (14:13 +0000)
Part of fix was to make edgering walker work when initial
edge is a wire edge (has no faces attached): it will just
walk that one edge and quit now.  I checked other uses
of the edgering walker and this won't hurt them.  Had
to add a new wireedge variable to the edge ring walker state.

source/blender/bmesh/intern/bmesh_walkers_impl.c
source/blender/bmesh/intern/bmesh_walkers_private.h
source/blender/editors/mesh/loopcut.c

index 90e658c380bd6562351bd9f6dd4b249dd8718c8b..e7dc82b57ca2750b4072271912f594ac818bfa68 100644 (file)
@@ -514,12 +514,18 @@ static void edgeringWalker_begin(BMWalker *walker, void *data)
        edgeringWalker *lwalk, owalk;
        BMEdge *e = data;
 
-       if (!e->l) return;
-
        BMW_pushstate(walker);
 
        lwalk = walker->currentstate;
        lwalk->l = e->l;
+
+       if (!lwalk->l) {
+               lwalk->wireedge = e;
+               return;
+       } else {
+               lwalk->wireedge = NULL;
+       }
+
        BLI_ghash_insert(walker->visithash, lwalk->l->e, NULL);
 
        /*rewind*/
@@ -546,17 +552,24 @@ static void *edgeringWalker_yield(BMWalker *walker)
        
        if (!lwalk) return NULL;
 
-       return lwalk->l->e;
+       if (lwalk->l)
+               return lwalk->l->e;
+       else
+               return lwalk->wireedge;
 }
 
 static void *edgeringWalker_step(BMWalker *walker)
 {
        edgeringWalker *lwalk = walker->currentstate;
-       BMEdge *e = lwalk->l->e;
+       BMEdge *e;
        BMLoop *l = lwalk->l /* , *origl = lwalk->l */;
 
        BMW_popstate(walker);
 
+       if (!l)
+               return lwalk->wireedge;
+
+       e = l->e;
        l = l->radial_next;
        l = l->next->next;
        
@@ -568,6 +581,7 @@ static void *edgeringWalker_step(BMWalker *walker)
                BMW_pushstate(walker);
                lwalk = walker->currentstate;
                lwalk->l = l;
+               lwalk->wireedge = NULL;
 
                BLI_ghash_insert(walker->visithash, l->e, NULL);
        }
index d4bc53d62a6d7d135efa2c6969fae87770fd1731..cc878cf25942bcbdddbbb0c2ed7c745f0be129e0 100644 (file)
@@ -66,6 +66,7 @@ typedef struct faceloopWalker {
 typedef struct edgeringWalker {
        struct edgeringWalker * prev;
        BMLoop *l;
+       BMEdge *wireedge;
 } edgeringWalker;
 
 typedef struct uvedgeWalker {
index 3b7d21199ea2dc7cfa2e36fe116de83be85f1aa1..ef99b07e09a386caa3733a1dc40791882feceac0 100644 (file)
@@ -249,7 +249,7 @@ static void edgering_sel(tringselOpData *lcd, int previewlines, int select)
                lasteed = eed;
        }
        
-       if (BM_Edge_Share_Faces(lasteed, startedge)) {
+       if (lasteed != startedge && BM_Edge_Share_Faces(lasteed, startedge)) {
                v[1][0] = v[0][0];
                v[1][1] = v[0][1];