[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43722] branches/bmesh/blender/source/ blender/bmesh/intern/bmesh_walkers_impl.c: Fix [#29984] Loop select crash on some wire edge meshes

Andrew Wiggin ender79bl at gmail.com
Thu Jan 26 13:39:57 CET 2012


Revision: 43722
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43722
Author:   ender79
Date:     2012-01-26 12:39:48 +0000 (Thu, 26 Jan 2012)
Log Message:
-----------
Fix [#29984] Loop select crash on some wire edge meshes

Crash was because the loop walker's wire edge handling wasn't general enough (handled only wire edges that were connected to exactly one other wire edge)

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_walkers_impl.c

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_walkers_impl.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_walkers_impl.c	2012-01-26 12:12:20 UTC (rev 43721)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_walkers_impl.c	2012-01-26 12:39:48 UTC (rev 43722)
@@ -393,7 +393,7 @@
 /*	Edge Loop Walker:
  *
  *	Starts at a tool-flagged edge and walks over the edge loop
- * 
+ *
 */
 
 static void loopWalker_begin(BMWalker *walker, void *data)
@@ -409,7 +409,7 @@
 
 	lwalk = BMW_addstate(walker);
 	BLI_ghash_insert(walker->visithash, e, NULL);
-	
+
 	lwalk->cur = lwalk->start = e;
 	lwalk->lastv = lwalk->startv = v;
 	lwalk->stage2 = 0;
@@ -444,40 +444,46 @@
 static void *loopWalker_step(BMWalker *walker)
 {
 	loopWalker *lwalk = BMW_currentstate(walker), owalk;
-	BMEdge *e = lwalk->cur /* , *nexte = NULL */;
+	BMIter eiter;
+	BMEdge *e = lwalk->cur, *nexte = NULL;
 	BMLoop *l, *l2;
 	BMVert *v;
 	int val, rlen /* , found=0 */, i=0, stopi;
 
 	owalk = *lwalk;
-	
-	if (e->v1 == lwalk->lastv) v = e->v2;
-	else v = e->v1;
+	BMW_removestate(walker);
 
-	val = BM_Vert_EdgeCount(v);
-	
-	BMW_removestate(walker);
-	
-	rlen = owalk.startrad;
 	l = e->l;
-	
-	/*handle wire edge case*/
-	if (!l && val == 2) {
-		e = bmesh_disk_nextedge(e, v);
-		
-		if (!BLI_ghash_haskey(walker->visithash, e)) {
-			lwalk = BMW_addstate(walker);
-			*lwalk = owalk;
-			lwalk->cur = e;
-			lwalk->lastv = v;
-			
-			BLI_ghash_insert(walker->visithash, e, NULL);			
+
+	/* handle wire edge case */
+	if (!l) {
+
+		/* match trunk: mark all connected wire edges */
+		for (i=0; i<2; i++) {
+			v = i ? e->v2 : e->v1;
+
+			BM_ITER(nexte, &eiter, walker->bm, BM_EDGES_OF_VERT, v) {
+				if ((nexte->l == NULL) && !BLI_ghash_haskey(walker->visithash, nexte)) {
+					lwalk = BMW_addstate(walker);
+					lwalk->cur = nexte;
+					lwalk->lastv = v;
+					lwalk->startrad = owalk.startrad;
+
+					BLI_ghash_insert(walker->visithash, nexte, NULL);
+				}
+			}
 		}
-		
+
 		return owalk.cur;
 	}
-	
-	if (val == 4 || val == 2 || rlen == 1) {		
+
+	v = (e->v1 == lwalk->lastv) ? e->v2 : e->v1;
+
+	val = BM_Vert_EdgeCount(v);
+
+	rlen = owalk.startrad;
+
+	if (val == 4 || val == 2 || rlen == 1) {
 		i = 0;
 		stopi = val / 2;
 		while (1) {
@@ -489,7 +495,7 @@
 				break;
 
 			l2 = bmesh_radial_nextloop(l);
-			
+
 			if (l2 == l) {
 				break;
 			}
@@ -498,20 +504,21 @@
 			i += 1;
 		}
 	}
-	
-	if (!l)
+
+	if (!l) {
 		return owalk.cur;
+	}
 
 	if (l != e->l && !BLI_ghash_haskey(walker->visithash, l->e)) {
 		if (!(rlen != 1 && i != stopi)) {
 			lwalk = BMW_addstate(walker);
-			*lwalk = owalk;
 			lwalk->cur = l->e;
 			lwalk->lastv = v;
+			lwalk->startrad = owalk.startrad;
 			BLI_ghash_insert(walker->visithash, l->e, NULL);
 		}
 	}
-	
+
 	return owalk.cur;
 }
 



More information about the Bf-blender-cvs mailing list