[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44682] trunk/blender/source/blender: fix for own error in edge-rotate keeping edge customdata - this was crashing when rotating multiple edges .

Campbell Barton ideasman42 at gmail.com
Tue Mar 6 20:29:08 CET 2012


Revision: 44682
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44682
Author:   campbellbarton
Date:     2012-03-06 19:29:05 +0000 (Tue, 06 Mar 2012)
Log Message:
-----------
fix for own error in edge-rotate keeping edge customdata - this was crashing when rotating multiple edges.

Now create the rotate edge in advance and copy its customdata (before joining the faces).

This commit also fixes an annoyance where tryangulating faces could create duplicate edges.

Modified Paths:
--------------
    trunk/blender/source/blender/bmesh/intern/bmesh_core.c
    trunk/blender/source/blender/bmesh/intern/bmesh_core.h
    trunk/blender/source/blender/bmesh/intern/bmesh_mods.c
    trunk/blender/source/blender/bmesh/intern/bmesh_mods.h
    trunk/blender/source/blender/bmesh/intern/bmesh_polygon.c
    trunk/blender/source/blender/bmesh/operators/bmo_connect.c
    trunk/blender/source/blender/bmesh/operators/bmo_dissolve.c
    trunk/blender/source/blender/bmesh/operators/bmo_join_triangles.c
    trunk/blender/source/blender/bmesh/operators/bmo_removedoubles.c
    trunk/blender/source/blender/bmesh/operators/bmo_subdivide.c
    trunk/blender/source/blender/bmesh/tools/BME_bevel.c
    trunk/blender/source/blender/editors/mesh/knifetool.c
    trunk/blender/source/blender/python/bmesh/bmesh_py_utils.c

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_core.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_core.c	2012-03-06 18:40:15 UTC (rev 44681)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_core.c	2012-03-06 19:29:05 UTC (rev 44682)
@@ -860,8 +860,6 @@
  * Joins a collected group of faces into one. Only restriction on
  * the input data is that the faces must be connected to each other.
  *
- * \param do_clear Remove the edges and verts shared by faces when joining.
- *
  * \return The newly created combine BMFace.
  *
  * \note If a pair of faces share multiple edges,
@@ -870,8 +868,7 @@
  * \note this is a generic, flexible join faces function,
  * almost everything uses this, including #BM_faces_join_pair
  */
-BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface,
-                      const short do_del)
+BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface)
 {
 	BMFace *f, *newf;
 #ifdef USE_BMESH_HOLES
@@ -1025,14 +1022,12 @@
 	}
 
 	/* delete old geometr */
-	if (do_del) {
-		for (i = 0; i < BLI_array_count(deledges); i++) {
-			BM_edge_kill(bm, deledges[i]);
-		}
+	for (i = 0; i < BLI_array_count(deledges); i++) {
+		BM_edge_kill(bm, deledges[i]);
+	}
 
-		for (i = 0; i < BLI_array_count(delverts); i++) {
-			BM_vert_kill(bm, delverts[i]);
-		}
+	for (i = 0; i < BLI_array_count(delverts); i++) {
+		BM_vert_kill(bm, delverts[i]);
 	}
 	
 	BLI_array_free(edges);
@@ -1114,7 +1109,8 @@
 #ifdef USE_BMESH_HOLES
                    ListBase *holes,
 #endif
-                   BMEdge *example
+                   BMEdge *example,
+                   const short nodouble
                    )
 {
 #ifdef USE_BMESH_HOLES
@@ -1139,7 +1135,7 @@
 	}
 
 	/* allocate new edge between v1 and v2 */
-	e = BM_edge_create(bm, v1, v2, example, FALSE);
+	e = BM_edge_create(bm, v1, v2, example, nodouble);
 
 	f2 = bm_face_create__sfme(bm, f);
 	f1loop = bm_loop_create(bm, v2, e, f, v2loop);

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_core.h
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_core.h	2012-03-06 18:40:15 UTC (rev 44681)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_core.h	2012-03-06 19:29:05 UTC (rev 44682)
@@ -44,8 +44,7 @@
 
 int  bmesh_loop_reverse(BMesh *bm, BMFace *f);
 
-BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface,
-                      const short do_del);
+BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface);
 
 /* EULER API - For modifying structure */
 BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1,
@@ -53,7 +52,8 @@
 #ifdef USE_BMESH_HOLES
                           ListBase *holes,
 #endif
-                          BMEdge *example
+                          BMEdge *example,
+                          const short nodouble
                           );
 
 BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **r_e);

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_mods.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_mods.c	2012-03-06 18:40:15 UTC (rev 44681)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_mods.c	2012-03-06 19:29:05 UTC (rev 44682)
@@ -133,7 +133,7 @@
 		 * increasing valence to four.  this may be hackish. .  */
 		BMLoop *loop = e->l;
 		if (loop->v == v) loop = loop->next;
-		if (!BM_face_split(bm, loop->f, v, loop->v, NULL, NULL))
+		if (!BM_face_split(bm, loop->f, v, loop->v, NULL, NULL, FALSE))
 			return FALSE;
 
 		if (!BM_disk_dissolve(bm, v)) {
@@ -153,7 +153,7 @@
 		f = e->l->f;
 		f2 = e->l->radial_next->f;
 
-		if (f != f2 && !BM_faces_join_pair(bm, f, f2, e, TRUE)) {
+		if (f != f2 && !BM_faces_join_pair(bm, f, f2, e)) {
 			return FALSE;
 		}
 
@@ -170,7 +170,7 @@
 				f = NULL;
 				len = bmesh_radial_length(e->l);
 				if (len == 2 && (e != baseedge) && (e != keepedge)) {
-					f = BM_faces_join_pair(bm, e->l->f, e->l->radial_next->f, e, TRUE);
+					f = BM_faces_join_pair(bm, e->l->f, e->l->radial_next->f, e);
 					/* return if couldn't join faces in manifold
 					 * conditions */
 					//!disabled for testing why bad things happen
@@ -200,7 +200,7 @@
 
 		if (f != f2) {
 			/* join two remaining face */
-			if (!BM_faces_join_pair(bm, f, f2, e, TRUE)) {
+			if (!BM_faces_join_pair(bm, f, f2, e)) {
 				return FALSE;
 			}
 		}
@@ -224,8 +224,7 @@
  *
  * \return pointer to the combined face
  */
-BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e,
-                           const short do_del)
+BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e)
 {
 	BMLoop *l1, *l2;
 	BMEdge *jed = NULL;
@@ -261,7 +260,7 @@
 		bmesh_loop_reverse(bm, f2);
 	}
 
-	f1 = BM_faces_join(bm, faces, 2, do_del);
+	f1 = BM_faces_join(bm, faces, 2);
 	
 	return f1;
 }
@@ -292,7 +291,7 @@
 			if (v_iter == v2) {
 				BMLoop *nl;
 
-				f_iter = BM_face_split(bm, f_iter, v1, v2, &nl, NULL);
+				f_iter = BM_face_split(bm, f_iter, v1, v2, &nl, NULL, FALSE);
 
 				if (r_f) {
 					*r_f = f_iter;
@@ -319,12 +318,14 @@
  * \param v1, v2 vertices which define the split edge, must be different
  * \param r_l pointer which will receive the BMLoop for the split edge in the new face
  * \param example Edge used for attributes of splitting edge, if non-NULL
+ * \param nodouble Use an existing edge if found
  *
  * \return Pointer to the newly created face representing one side of the split
  * if the split is successful (and the original original face will be the
  * other side). NULL if the split fails.
  */
-BMFace *BM_face_split(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **r_l, BMEdge *example)
+BMFace *BM_face_split(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, BMLoop **r_l,
+                      BMEdge *example, const short nodouble)
 {
 	const int has_mdisp = CustomData_has_layer(&bm->ldata, CD_MDISPS);
 	BMFace *nf, *of;
@@ -337,9 +338,9 @@
 	}
 	
 #ifdef USE_BMESH_HOLES
-	nf = bmesh_sfme(bm, f, v1, v2, r_l, NULL, example);
+	nf = bmesh_sfme(bm, f, v1, v2, r_l, NULL, example, nodouble);
 #else
-	nf = bmesh_sfme(bm, f, v1, v2, r_l, example);
+	nf = bmesh_sfme(bm, f, v1, v2, r_l, example, nodouble);
 #endif
 	
 	if (nf) {
@@ -408,9 +409,9 @@
 		r_l = &l_dummy;
 	
 #ifdef USE_BMESH_HOLES
-	nf = bmesh_sfme(bm, f, v1, v2, r_l, NULL, example);
+	nf = bmesh_sfme(bm, f, v1, v2, r_l, NULL, example, FALSE);
 #else
-	nf = bmesh_sfme(bm, f, v1, v2, r_l, example);
+	nf = bmesh_sfme(bm, f, v1, v2, r_l, example, FALSE);
 #endif
 	/* bmesh_sfme returns in r_l a Loop for nf going from v1 to v2.
 	 * The radial_next is for f and goes from v2 to v1  */
@@ -522,10 +523,10 @@
 		}
 
 		if (BLI_array_count(faces) >= 2) {
-			BMFace *f2 = BM_faces_join(bm, faces, BLI_array_count(faces), TRUE);
+			BMFace *f2 = BM_faces_join(bm, faces, BLI_array_count(faces));
 			if (f2) {
 				BMLoop *nl = NULL;
-				if (BM_face_split(bm, f2, tv, tv2, &nl, NULL)) {
+				if (BM_face_split(bm, f2, tv, tv2, &nl, NULL, FALSE)) {
 					ne = nl->e;
 				}
 			}
@@ -995,9 +996,9 @@
 BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, const short ccw, const short check_flag)
 {
 	BMVert *v1, *v2;
-	BMLoop *l1, *l2, *nl;
+	BMLoop *l1, *l2;
 	BMFace *f;
-	BMEdge *e_splice = NULL;
+	BMEdge *e_new = NULL;
 
 	if (!BM_edge_rotate_check(bm, e)) {
 		return NULL;
@@ -1021,10 +1022,7 @@
 	}
 
 	/* check before applying */
-	if (check_flag & BM_EDGEROT_CHECK_SPLICE) {
-		e_splice = BM_edge_exists(v1, v2);
-	}
-	else if (check_flag & BM_EDGEROT_CHECK_EXISTS) {
+	if (check_flag & BM_EDGEROT_CHECK_EXISTS) {
 		if (BM_edge_exists(v1, v2)) {
 			return NULL;
 		}
@@ -1044,8 +1042,12 @@
 	/* --------------- */
 	/* Rotate The Edge */
 
+	/* first create the new edge, this is so we can copy the customdata from the old one
+	 * if splice if disabled, always add in a new edge even if theres one there. */
+	e_new = BM_edge_create(bm, v1, v2, e, (check_flag & BM_EDGEROT_CHECK_SPLICE)!=0);
+
 	/* don't delete the edge, manually remove the egde after so we can copy its attributes */
-	f = BM_faces_join_pair(bm, l1->f, l2->f, e, FALSE);
+	f = BM_faces_join_pair(bm, l1->f, l2->f, NULL);
 
 	if (f == NULL) {
 		return NULL;
@@ -1054,19 +1056,11 @@
 	/* note, this assumes joining the faces _didnt_ also remove the verts.
 	 * the #BM_edge_rotate_check will ensure this, but its possibly corrupt state or future edits
 	 * break this */
-
-	if (!BM_face_split(bm, f, v1, v2, &nl, e))
+	if (!BM_face_split(bm, f, v1, v2, NULL, NULL, TRUE)) {
 		return NULL;
-
-	/* edge has done its job as an example, now remove */
-	BM_edge_kill(bm, e);
-
-	/* replace existing edge (kill e_splice) */
-	if (e_splice) {
-		BM_edge_splice(bm, e_splice, nl->e);
 	}
 
-	return nl->e;
+	return e_new;
 }
 
 /**

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_mods.h
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_mods.h	2012-03-06 18:40:15 UTC (rev 44681)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_mods.h	2012-03-06 19:29:05 UTC (rev 44682)
@@ -33,14 +33,14 @@
 
 int BM_disk_dissolve(BMesh *bm, BMVert *v);
 
-BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e,
-                           const short do_del);
+BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e);
 
 BMEdge *BM_verts_connect(BMesh *bm, BMVert *v1, BMVert *v2, BMFace **r_f);
 
 BMFace *BM_face_split(BMesh *bm, BMFace *f,
                       BMVert *v1, BMVert *v2,
-                      BMLoop **r_l, BMEdge *example);
+                      BMLoop **r_l,
+                      BMEdge *example, const short nodouble);
 
 BMFace *BM_face_split_n(BMesh *bm, BMFace *f,
                       BMVert *v1, BMVert *v2,

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_polygon.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_polygon.c	2012-03-06 18:40:15 UTC (rev 44681)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_polygon.c	2012-03-06 19:29:05 UTC (rev 44682)
@@ -835,7 +835,7 @@
 			/* v = l->v; */ /* UNUSED */
 			f = BM_face_split(bm, l_iter->f, l_iter->prev->v,
 			                  l_iter->next->v,
-			                  &newl, NULL);
+			                  &newl, NULL, TRUE);
 
 			if (UNLIKELY(!f)) {

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list