[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43491] branches/bmesh/blender/source/ blender/bmesh: fixed [#29907] Uncoherent behaviour of Delete Edge Loop

Campbell Barton ideasman42 at gmail.com
Wed Jan 18 13:31:49 CET 2012


Revision: 43491
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43491
Author:   campbellbarton
Date:     2012-01-18 12:31:41 +0000 (Wed, 18 Jan 2012)
Log Message:
-----------
fixed [#29907] Uncoherent behaviour of Delete Edge Loop

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

Modified: branches/bmesh/blender/source/blender/bmesh/bmesh.h
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/bmesh.h	2012-01-18 11:41:35 UTC (rev 43490)
+++ branches/bmesh/blender/source/blender/bmesh/bmesh.h	2012-01-18 12:31:41 UTC (rev 43491)
@@ -210,7 +210,7 @@
                       struct BMLoop **nl, BMEdge *example);
 
 /* these 2 functions are very similar */
-BMEdge* BM_Collapse_Vert_Faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac);
+BMEdge* BM_Collapse_Vert_Faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac, const int join_faces);
 BMEdge* BM_Collapse_Vert_Edges(BMesh *bm, BMEdge *ke, BMVert *kv);
 
 

Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mods.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mods.c	2012-01-18 11:41:35 UTC (rev 43490)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_mods.c	2012-01-18 12:31:41 UTC (rev 43491)
@@ -138,7 +138,7 @@
 	}
 	else if (keepedge == NULL && len == 2) {
 		/*collapse the vertex*/
-		e = BM_Collapse_Vert_Faces(bm, v->e, v, 1.0);
+		e = BM_Collapse_Vert_Faces(bm, v->e, v, 1.0, TRUE);
 
 		if (!e) {
 			return 0;
@@ -181,7 +181,7 @@
 		}
 
 		/*collapse the vertex*/
-		e = BM_Collapse_Vert_Faces(bm, baseedge, v, 1.0);
+		e = BM_Collapse_Vert_Faces(bm, baseedge, v, 1.0, TRUE);
 
 		if (!e) {
 			return 0;
@@ -230,7 +230,7 @@
 				}
 			};
 		}
-		BM_Collapse_Vert_Faces(bm, v->e, v, 1.0);
+		BM_Collapse_Vert_Faces(bm, v->e, v, 1.0, TRUE);
 	}
 }
 #endif
@@ -399,11 +399,13 @@
  *  BMESH_TODO:
  *    Insert error checking for KV valance.
  *
- *  Returns -
- *	The New Edge
+ * @param fac The factor along the edge
+ * @param join_faces When true the faces around the vertex will be joined
+ * otherwise collapse the vertex by merging the 2 edges this vert touches into one.
+ *  @returns The New Edge
  */
 
-BMEdge* BM_Collapse_Vert_Faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac)
+BMEdge* BM_Collapse_Vert_Faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac, const int join_faces)
 {
 	BMEdge *ne = NULL;
 	BMVert *tv = bmesh_edge_getothervert(ke, kv);
@@ -413,8 +415,6 @@
 
 	BMIter iter;
 	BMLoop *l=NULL, *kvloop=NULL, *tvloop=NULL;
-	BMFace **faces = NULL, *f;
-	BLI_array_staticdeclare(faces, 8);
 
 	void *src[2];
 	float w[2];
@@ -423,6 +423,7 @@
 	BLI_assert(bmesh_disk_count(kv) <= 2);
 
 
+	/* first modify the face loop data  */
 	w[0] = 1.0f - fac;
 	w[1] = fac;
 
@@ -441,32 +442,40 @@
 		} while (l != ke->l);
 	}
 
-	BM_ITER(f, &iter, bm, BM_FACES_OF_VERT, kv) {
-		BLI_array_append(faces, f);
-	}
-
+	/* now interpolate the vertex data */
 	BM_Data_Interp_From_Verts(bm, kv, tv, kv, fac);
 
 	e2 = bmesh_disk_nextedge(ke, kv);
 	tv2 = BM_OtherEdgeVert(e2, kv);
 
-	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)) {
-				ne = nl->e;
+	if (join_faces) {
+		BMFace **faces = NULL, *f;
+		BLI_array_staticdeclare(faces, 8);
+
+		BM_ITER(f, &iter, bm, BM_FACES_OF_VERT, kv) {
+			BLI_array_append(faces, f);
+		}
+
+		if (BLI_array_count(faces) >= 2) {
+			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)) {
+					ne = nl->e;
+				}
 			}
 		}
+
+		BLI_array_free(faces);
+
+		return ne;
 	}
-	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);
+	/* 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);
 
 	return ne;
 }
@@ -477,17 +486,15 @@
  *
  * Collapses a vertex onto another vertex it shares an edge with.
  *
- * Note that this is not a general edge collapse function.
- *
- * Note this function is very close to 'BM_Collapse_Vert_Faces', both collapse
- * a vertex and return a new edge. Except this doesn't merge customdata.
- *
  * Returns -
  * The New Edge
  */
 
-BMEdge* BM_Collapse_Vert_Edges(BMesh *bm, BMEdge *ke, BMVert *kv)
+BMEdge *BM_Collapse_Vert_Edges(BMesh *bm, BMEdge *ke, BMVert *kv)
 {
+	/* nice example implimentation but we want loops to have their customdata
+	 * accounted for.*/
+#if 0
 	BMEdge *ne = NULL;
 
 	/* Collapse between 2 edges */
@@ -509,6 +516,11 @@
 	}
 
 	return ne;
+#else
+	/* with these args faces are never joined, same as above
+	 * but account for loop customdata */
+	return BM_Collapse_Vert_Faces(bm, ke, kv, 1.0f, FALSE);
+#endif
 }
 
 #undef DO_V_INTERP

Modified: branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c	2012-01-18 11:41:35 UTC (rev 43490)
+++ branches/bmesh/blender/source/blender/bmesh/operators/dissolveops.c	2012-01-18 12:31:41 UTC (rev 43491)
@@ -167,8 +167,9 @@
 
 	/*clean up extreneous 2-valence vertices*/
 	for (i=0; i<BLI_array_count(verts); i++) {
-		if (verts[i]->e)
-			BM_Collapse_Vert_Faces(bm, verts[i]->e, verts[i], 1.0);
+		if (verts[i]->e) {
+			BM_Collapse_Vert_Edges(bm, verts[i]->e, verts[i]);
+		}
 	}
 	
 	BLI_array_free(verts);
@@ -223,8 +224,8 @@
 			BMVert *v1= e->v1, *v2= e->v2;
 
 			/*collapse the vert*/
-			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);
+			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);
 
 		}
 	}
@@ -233,7 +234,7 @@
 	BM_ITER(v, &viter, bm, BM_VERTS_OF_MESH, NULL) {
 		if (BMO_TestFlag(bm, v, VERT_MARK)) {
 			if (BM_Vert_EdgeCount(v) == 2) {
-				bmesh_jekv(bm, v->e, v);
+				BM_Collapse_Vert_Edges(bm, v->e, v);
 			}
 		}
 	}
@@ -297,7 +298,7 @@
 			if (BM_Vert_EdgeCount(v) == 2) {
 
 				/*collapse the vert*/
-				BM_Collapse_Vert_Faces(bm, v->e, v, 1.0f);
+				BM_Collapse_Vert_Faces(bm, v->e, v, 1.0f, TRUE);
 				continue;
 			}
 

Modified: branches/bmesh/blender/source/blender/bmesh/tools/BME_bevel.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/tools/BME_bevel.c	2012-01-18 11:41:35 UTC (rev 43490)
+++ branches/bmesh/blender/source/blender/bmesh/tools/BME_bevel.c	2012-01-18 12:31:41 UTC (rev 43491)
@@ -438,7 +438,7 @@
 
 		//void BM_Collapse_Vert_Faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac, int calcnorm){
 		//hrm, why is there a fac here? it just removes a vert
-		BM_Collapse_Vert_Faces(bm, v->e, v, 1.0, 0);
+		BM_Collapse_Vert_Faces(bm, v->e, v, 1.0, TRUE);
 		//bmesh_jekv(bm,v->e,v);
 	}
 
@@ -486,14 +486,14 @@
 		if (kl->v == kv) {
 			BM_Split_Face(bm,kl->f,kl->prev->v,kl->next->v,&nl,kl->prev->e);
 			bmesh_jfke(bm, kl->prev->radial_next->f,kl->f,kl->prev->e);
-			BM_Collapse_Vert_Faces(bm, kl->e, kv, 1.0);
+			BM_Collapse_Vert_Faces(bm, kl->e, kv, 1.0, TRUE);
 			//BME_JEKV(bm,kl->e,kv);
 			
 		}
 		else {
 			BM_Split_Face(bm,kl->f,kl->next->next->v,kl->v,&nl,kl->next->e);
 			bmesh_jfke(bm, kl->next->radial_next->f,kl->f,kl->next->e);
-			BM_Collapse_Vert_Faces(bm, kl->e, kv, 1.0);
+			BM_Collapse_Vert_Faces(bm, kl->e, kv, 1.0, TRUE);
 			//BME_JEKV(bm,kl->e,kv);
 		}
 		l = l->prev;
@@ -523,13 +523,13 @@
 		if (kl->v == kv) {
 			BM_Split_Face(bm,kl->f,kl->prev->v,kl->next->v,&nl,kl->prev->e);
 			bmesh_jfke(bm,kl->prev->radial_next->f,kl->f,kl->prev->e);
-			BM_Collapse_Vert_Faces(bm, kl->e, kv, 1.0);
+			BM_Collapse_Vert_Faces(bm, kl->e, kv, 1.0, TRUE);
 			//BME_JEKV(bm,kl->e,kv);
 		}
 		else {
 			BM_Split_Face(bm,kl->f,kl->next->next->v,kl->v,&nl,kl->next->e);
 			bmesh_jfke(bm, kl->next->radial_next->f,kl->f,kl->next->e);
-			BM_Collapse_Vert_Faces(bm, kl->e, kv, 1.0);
+			BM_Collapse_Vert_Faces(bm, kl->e, kv, 1.0, TRUE);
 			//BME_JEKV(bm,kl->e,kv);
 		}
 	}



More information about the Bf-blender-cvs mailing list