[Bf-blender-cvs] [dd8a9ee] master: Fix T40162: Vert connect creates extra face cutting across concave NGon.

Campbell Barton noreply at git.blender.org
Tue May 13 09:57:12 CEST 2014


Commit: dd8a9eee3b403e91543e358b2ecffd40d3adaa6b
Author: Campbell Barton
Date:   Tue May 13 17:50:11 2014 +1000
https://developer.blender.org/rBdd8a9eee3b403e91543e358b2ecffd40d3adaa6b

Fix T40162: Vert connect creates extra face cutting across concave NGon.

We need to support cutting degenerate ngons, see: T39418
This commit disallows cuts across faces where the same vertices can create better cuts on different faces.

===================================================================

M	source/blender/bmesh/intern/bmesh_polygon.c
M	source/blender/bmesh/intern/bmesh_polygon.h
M	source/blender/bmesh/operators/bmo_connect.c

===================================================================

diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c
index 32b9d81..ed12c64 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.c
+++ b/source/blender/bmesh/intern/bmesh_polygon.c
@@ -1104,6 +1104,21 @@ void BM_face_splits_check_legal(BMFace *f, BMLoop *(*loops)[2], int len)
 	}
 }
 
+/**
+ * This simply checks that the verts don't connect faces which would have more optimal splits.
+ * but _not_ check for correctness.
+ */
+void BM_face_splits_check_optimal(BMFace *f, BMLoop *(*loops)[2], int len)
+{
+	int i;
+
+	for (i = 0; i < len; i++) {
+		BMLoop *l_a_dummy, *l_b_dummy;
+		if (f != BM_vert_pair_share_face_by_angle(loops[i][0]->v, loops[i][1]->v, &l_a_dummy, &l_b_dummy, false)) {
+			loops[i][0] = NULL;
+		}
+	}
+}
 
 /**
  * Small utility functions for fast access
diff --git a/source/blender/bmesh/intern/bmesh_polygon.h b/source/blender/bmesh/intern/bmesh_polygon.h
index 7200d47..d903b77 100644
--- a/source/blender/bmesh/intern/bmesh_polygon.h
+++ b/source/blender/bmesh/intern/bmesh_polygon.h
@@ -63,6 +63,7 @@ void  BM_face_triangulate(BMesh *bm, BMFace *f,
                           const bool use_tag) ATTR_NONNULL(1, 2);
 
 void  BM_face_splits_check_legal(BMFace *f, BMLoop *(*loops)[2], int len) ATTR_NONNULL();
+void  BM_face_splits_check_optimal(BMFace *f, BMLoop *(*loops)[2], int len) ATTR_NONNULL();
 
 void BM_face_as_array_vert_tri(BMFace *f, BMVert *r_verts[3]) ATTR_NONNULL();
 void BM_face_as_array_vert_quad(BMFace *f, BMVert *r_verts[4]) ATTR_NONNULL();
diff --git a/source/blender/bmesh/operators/bmo_connect.c b/source/blender/bmesh/operators/bmo_connect.c
index f7a14f4..0848ae8 100644
--- a/source/blender/bmesh/operators/bmo_connect.c
+++ b/source/blender/bmesh/operators/bmo_connect.c
@@ -84,6 +84,9 @@ static int bm_face_connect_verts(BMesh *bm, BMFace *f, const bool check_degenera
 	if (check_degenerate) {
 		BM_face_splits_check_legal(f, loops_split, STACK_SIZE(loops_split));
 	}
+	else {
+		BM_face_splits_check_optimal(f, loops_split, STACK_SIZE(loops_split));
+	}
 
 	for (i = 0; i < STACK_SIZE(loops_split); i++) {
 		BMVert **v_pair;




More information about the Bf-blender-cvs mailing list