[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60943] trunk/blender/source/blender/bmesh /intern/bmesh_mods.c: fix for BM_faces_join_pair() making the assumption that only the 2 faces use an edge, face winding could be flipped incorrectly.

Campbell Barton ideasman42 at gmail.com
Sat Oct 26 07:05:38 CEST 2013


Revision: 60943
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60943
Author:   campbellbarton
Date:     2013-10-26 05:05:37 +0000 (Sat, 26 Oct 2013)
Log Message:
-----------
fix for BM_faces_join_pair() making the assumption that only the 2 faces use an edge, face winding could be flipped incorrectly.

also remove search for shared edges - all callers pass the edge in.

Modified Paths:
--------------
    trunk/blender/source/blender/bmesh/intern/bmesh_mods.c

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_mods.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_mods.c	2013-10-26 04:07:18 UTC (rev 60942)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_mods.c	2013-10-26 05:05:37 UTC (rev 60943)
@@ -231,49 +231,24 @@
  * to be reconsidered.
  *
  * If the windings do not match the winding of the new face will follow
- * \a f1's winding (i.e. \a f2 will be reversed before the join).
+ * \a f_a's winding (i.e. \a f_b will be reversed before the join).
  *
  * \return pointer to the combined face
  */
-BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e, const bool do_del)
+BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f_a, BMFace *f_b, BMEdge *e, const bool do_del)
 {
-	BMLoop *l1, *l2;
-	BMEdge *jed = NULL;
-	BMFace *faces[2] = {f1, f2};
-	
-	jed = e;
-	if (!jed) {
-		BMLoop *l_first;
-		/* search for an edge that has both these faces in its radial cycle */
-		l1 = l_first = BM_FACE_FIRST_LOOP(f1);
-		do {
-			if (l1->radial_next->f == f2) {
-				jed = l1->e;
-				break;
-			}
-		} while ((l1 = l1->next) != l_first);
-	}
+	BMFace *faces[2] = {f_a, f_b};
 
-	if (UNLIKELY(!jed)) {
-		BMESH_ASSERT(0);
-		return NULL;
+	BMLoop *l_a = BM_face_edge_share_loop(f_a, e);
+	BMLoop *l_b = BM_face_edge_share_loop(f_b, e);
+
+	BLI_assert(l_a && l_b);
+
+	if (l_a->v == l_b->v) {
+		bmesh_loop_reverse(bm, f_b);
 	}
 	
-	l1 = jed->l;
-	
-	if (UNLIKELY(!l1)) {
-		BMESH_ASSERT(0);
-		return NULL;
-	}
-	
-	l2 = l1->radial_next;
-	if (l1->v == l2->v) {
-		bmesh_loop_reverse(bm, f2);
-	}
-
-	f1 = BM_faces_join(bm, faces, 2, do_del);
-	
-	return f1;
+	return BM_faces_join(bm, faces, 2, do_del);
 }
 
 /**
@@ -1074,7 +1049,7 @@
 	f_hflag_prev_2 = l2->f->head.hflag;
 
 	/* don't delete the edge, manually remove the edge after so we can copy its attributes */
-	f = BM_faces_join_pair(bm, l1->f, l2->f, NULL, true);
+	f = BM_faces_join_pair(bm, l1->f, l2->f, e, true);
 
 	if (f == NULL) {
 		return NULL;




More information about the Bf-blender-cvs mailing list