[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43438] branches/bmesh/blender/source/ blender/bmesh: fix own error [#28645] TODO: dissolve edges doesn' t delete lonely vertices on edges

Campbell Barton ideasman42 at gmail.com
Tue Jan 17 04:40:49 CET 2012


Revision: 43438
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43438
Author:   campbellbarton
Date:     2012-01-17 03:40:37 +0000 (Tue, 17 Jan 2012)
Log Message:
-----------
fix own error [#28645] TODO: dissolve edges doesn't delete lonely vertices on edges

made this mistake when refactoring edge collapse code, though overall I think the function works better then before now.

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mods.c
    branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mods.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mods.c	2012-01-17 02:20:23 UTC (rev 43437)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mods.c	2012-01-17 03:40:37 UTC (rev 43438)
@@ -408,17 +408,21 @@
 	BMEdge *ne = NULL;
 	BMVert *tv = bmesh_edge_getothervert(ke, kv);
 
+	BMEdge *e2;
+	BMVert *tv2;
 
 	BMIter iter;
 	BMLoop *l=NULL, *kvloop=NULL, *tvloop=NULL;
 	BMFace **faces = NULL, *f;
 	BLI_array_staticdeclare(faces, 8);
+
 	void *src[2];
 	float w[2];
 
 	/* Only intended to be called for 2-valence vertices */
 	BLI_assert(bmesh_disk_count(kv) <= 2);
 
+
 	w[0] = 1.0f - fac;
 	w[1] = fac;
 
@@ -441,19 +445,13 @@
 		BLI_array_append(faces, f);
 	}
 
-	/* Collapse between 2+ faces */
-	if (faces && BLI_array_count(faces) > 1) {
-		BMFace *f2;
-		BMEdge *e2;
-		BMVert *tv2;
+	BM_Data_Interp_From_Verts(bm, kv, tv, kv, fac);
 
-		/* only call when making real changes */
-		BM_Data_Interp_From_Verts(bm, kv, tv, kv, fac);
+	e2 = bmesh_disk_nextedge(ke, kv);
+	tv2 = BM_OtherEdgeVert(e2, kv);
 
-		e2 = bmesh_disk_nextedge(ke, kv);
-		tv2 = BM_OtherEdgeVert(e2, kv);
-
-		f2 = BM_Join_Faces(bm, faces, BLI_array_count(faces));
+	if (BLI_array_count(faces) > 1) {
+		BMFace *f2 = BM_Join_Faces(bm, faces, BLI_array_count(faces));
 		if (f2) {
 			BMLoop *nl = NULL;
 			if (BM_Split_Face(bm, f2, tv, tv2, &nl, NULL)) {
@@ -461,7 +459,12 @@
 			}
 		}
 	}
-	/* else we cant do anything! */
+	else { /* single face or no faces */
+		/* same as BM_Collapse_Vert_Edges() however we already
+		 * have vars to perform this operation so dont call. */
+		bmesh_jekv(bm, ke, kv);
+		ne = BM_Edge_Exist(tv, tv2);
+	}
 
 	BLI_array_free(faces);
 
@@ -472,8 +475,7 @@
 /**
  *			BM_Collapse_Vert_Edges
  *
- * Collapses a vertex onto another vertex it shares an edge with. Fac defines
- * the amount of interpolation for Custom Data.
+ * Collapses a vertex onto another vertex it shares an edge with.
  *
  * Note that this is not a general edge collapse function.
  *

Modified: branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c	2012-01-17 02:20:23 UTC (rev 43437)
+++ branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c	2012-01-17 03:40:37 UTC (rev 43438)
@@ -159,10 +159,9 @@
 
 	BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
 		if (BMO_TestFlag(bm, v, VERT_MARK) && 
-			BM_Vert_EdgeCount(v) == 2) 
+			BM_Vert_EdgeCount(v) == 2)
 		{
-			BLI_array_growone(verts);
-			verts[BLI_array_count(verts)-1] = v;
+			BLI_array_append(verts, v);
 		}
 	}
 
@@ -224,8 +223,8 @@
 			BMVert *v1= e->v1, *v2= e->v2;
 
 			/*collapse the vert*/
-			if (BM_Vert_EdgeCount(v1) == 2) BM_Collapse_Vert_Edges(bm, v1->e, v1);
-			if (BM_Vert_EdgeCount(v2) == 2) BM_Collapse_Vert_Edges(bm, v2->e, v2);
+			if (BM_Vert_EdgeCount(v1) == 2) BM_Collapse_Vert_Faces(bm, v1->e, v1, 1.0f);
+			if (BM_Vert_EdgeCount(v2) == 2) BM_Collapse_Vert_Faces(bm, v2->e, v2, 1.0f);
 
 		}
 	}
@@ -298,7 +297,7 @@
 			if (BM_Vert_EdgeCount(v) == 2) {
 
 				/*collapse the vert*/
-				BM_Collapse_Vert_Edges(bm, v->e, v);
+				BM_Collapse_Vert_Faces(bm, v->e, v, 1.0f);
 				continue;
 			}
 



More information about the Bf-blender-cvs mailing list