[Bf-blender-cvs] [52d31b4894a] master: BMesh: make edge winding from face optional

Campbell Barton noreply at git.blender.org
Wed Mar 13 09:58:25 CET 2019


Commit: 52d31b4894a308b015fd111ad7872bd78f99fba6
Author: Campbell Barton
Date:   Wed Mar 13 19:55:18 2019 +1100
Branches: master
https://developer.blender.org/rB52d31b4894a308b015fd111ad7872bd78f99fba6

BMesh: make edge winding from face optional

Broke uv-sphere creation, further it might be a problem
for script authors expecting matching edge order for duplicated content.

Now only apply this when duplicating via the operator.

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

M	source/blender/bmesh/intern/bmesh_opdefines.c
M	source/blender/bmesh/operators/bmo_dupe.c
M	source/blender/editors/mesh/editmesh_tools.c

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

diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index e7585cc1836..35543aa23ce 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -1391,6 +1391,7 @@ static BMOpDefine bmo_duplicate_def = {
 	/* destination bmesh, if NULL will use current on */
 	 {"dest", BMO_OP_SLOT_PTR, {(int)BMO_OP_SLOT_SUBTYPE_PTR_BMESH}},
 	 {"use_select_history", BMO_OP_SLOT_BOOL},
+	 {"use_edge_flip_from_face", BMO_OP_SLOT_BOOL},
 	 {{'\0'}},
 	},
 	/* slots_out */
diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c
index a5ad162b586..b2961c5cb6b 100644
--- a/source/blender/bmesh/operators/bmo_dupe.c
+++ b/source/blender/bmesh/operators/bmo_dupe.c
@@ -75,7 +75,8 @@ static BMEdge *bmo_edge_copy(
         BMOpSlot *slot_boundarymap_out,
         BMesh *bm_dst, BMesh *bm_src,
         BMEdge *e_src,
-        GHash *vhash, GHash *ehash)
+        GHash *vhash, GHash *ehash,
+        const bool use_edge_flip_from_face)
 {
 	BMEdge *e_dst;
 	BMVert *e_dst_v1, *e_dst_v2;
@@ -121,10 +122,12 @@ static BMEdge *bmo_edge_copy(
 	/* Mark the edge for output */
 	BMO_edge_flag_enable(bm_dst, e_dst, DUPE_NEW);
 
-	/* Take winding from previous face (if we had one),
-	 * otherwise extruding a duplicated edges gives bad normals, see: T62487. */
-	if (BM_edge_is_boundary(e_src) && (e_src->l->v == e_src->v1)) {
-		BM_edge_verts_swap(e_dst);
+	if (use_edge_flip_from_face) {
+		/* Take winding from previous face (if we had one),
+		 * otherwise extruding a duplicated edges gives bad normals, see: T62487. */
+		if (BM_edge_is_boundary(e_src) && (e_src->l->v == e_src->v1)) {
+			BM_edge_verts_swap(e_dst);
+		}
 	}
 
 	return e_dst;
@@ -190,6 +193,7 @@ static BMFace *bmo_face_copy(
 static void bmo_mesh_copy(BMOperator *op, BMesh *bm_dst, BMesh *bm_src)
 {
 	const bool use_select_history = BMO_slot_bool_get(op->slots_in, "use_select_history");
+	const bool use_edge_flip_from_face = BMO_slot_bool_get(op->slots_in, "use_edge_flip_from_face");
 
 	BMVert *v = NULL, *v2;
 	BMEdge *e = NULL;
@@ -259,7 +263,7 @@ static void bmo_mesh_copy(BMOperator *op, BMesh *bm_dst, BMesh *bm_src)
 			}
 			/* now copy the actual edge */
 			bmo_edge_copy(op, slot_edge_map_out, slot_boundary_map_out,
-			              bm_dst, bm_src, e, vhash, ehash);
+			              bm_dst, bm_src, e, vhash, ehash, use_edge_flip_from_face);
 			BMO_edge_flag_enable(bm_src, e, DUPE_DONE);
 		}
 	}
@@ -279,7 +283,7 @@ static void bmo_mesh_copy(BMOperator *op, BMesh *bm_dst, BMesh *bm_src)
 			BM_ITER_ELEM (e, &eiter, f, BM_EDGES_OF_FACE) {
 				if (!BMO_edge_flag_test(bm_src, e, DUPE_DONE)) {
 					bmo_edge_copy(op, slot_edge_map_out, slot_boundary_map_out,
-					              bm_dst, bm_src, e, vhash, ehash);
+					              bm_dst, bm_src, e, vhash, ehash, use_edge_flip_from_face);
 					BMO_edge_flag_enable(bm_src, e, DUPE_DONE);
 				}
 			}
diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c
index 273003c3ccd..17ddb48cbdc 100644
--- a/source/blender/editors/mesh/editmesh_tools.c
+++ b/source/blender/editors/mesh/editmesh_tools.c
@@ -1748,8 +1748,8 @@ static int edbm_duplicate_exec(bContext *C, wmOperator *op)
 
 		EDBM_op_init(
 		        em, &bmop, op,
-		        "duplicate geom=%hvef use_select_history=%b",
-		        BM_ELEM_SELECT, true);
+		        "duplicate geom=%hvef use_select_history=%b use_edge_flip_from_face=%b",
+		        BM_ELEM_SELECT, true, true);
 
 		BMO_op_exec(bm, &bmop);



More information about the Bf-blender-cvs mailing list