[Bf-blender-cvs] [c3e454b8e08] master: Fix T60099: Inconsistent normals from spin tool

Campbell Barton noreply at git.blender.org
Fri Jan 4 06:24:12 CET 2019


Commit: c3e454b8e0808c8615cd58d86547e63642cde91d
Author: Campbell Barton
Date:   Fri Jan 4 16:23:04 2019 +1100
Branches: master
https://developer.blender.org/rBc3e454b8e0808c8615cd58d86547e63642cde91d

Fix T60099: Inconsistent normals from spin tool

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

M	source/blender/bmesh/intern/bmesh_opdefines.c
M	source/blender/bmesh/operators/bmo_dupe.c
M	source/blender/bmesh/operators/bmo_extrude.c

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

diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c
index 7a6cb814cc9..2cae6fb3823 100644
--- a/source/blender/bmesh/intern/bmesh_opdefines.c
+++ b/source/blender/bmesh/intern/bmesh_opdefines.c
@@ -1061,6 +1061,7 @@ static BMOpDefine bmo_extrude_face_region_def = {
 	 {"edges_exclude", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_EMPTY}},
 	 {"use_keep_orig", BMO_OP_SLOT_BOOL},   /* keep original geometry (requires ``geom`` to include edges). */
 	 {"use_normal_flip", BMO_OP_SLOT_BOOL},  /* Create faces with reversed direction. */
+	 {"use_normal_from_adjacent", BMO_OP_SLOT_BOOL},  /* Use winding from surrounding faces instead of this region. */
 	 {"use_select_history", BMO_OP_SLOT_BOOL},  /* pass to duplicate */
 	 {{'\0'}},
 	},
diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c
index 7f13731dc02..9dd4eded002 100644
--- a/source/blender/bmesh/operators/bmo_dupe.c
+++ b/source/blender/bmesh/operators/bmo_dupe.c
@@ -525,8 +525,9 @@ void bmo_spin_exec(BMesh *bm, BMOperator *op)
 			BMO_op_finish(bm, &dupop);
 		}
 		else {
-			BMO_op_initf(bm, &extop, op->flag, "extrude_face_region geom=%S use_normal_flip=%b",
-			             op, "geom_last.out", use_normal_flip && (a == 0));
+			BMO_op_initf(bm, &extop, op->flag,
+			             "extrude_face_region geom=%S use_normal_flip=%b use_normal_from_adjacent=%b",
+			             op, "geom_last.out", use_normal_flip && (a == 0), (a != 0));
 			BMO_op_exec(bm, &extop);
 			if ((use_merge && (a == steps - 1)) == false) {
 				BMO_op_callf(bm, op->flag,
diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c
index 8c1624740da..a13024d8793 100644
--- a/source/blender/bmesh/operators/bmo_extrude.c
+++ b/source/blender/bmesh/operators/bmo_extrude.c
@@ -339,6 +339,7 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
 	BMOpSlot *slot_facemap_out;
 	BMOpSlot *slot_edges_exclude;
 	const bool use_normal_flip = BMO_slot_bool_get(op->slots_in, "use_normal_flip");
+	const bool use_normal_from_adjacent = BMO_slot_bool_get(op->slots_in, "use_normal_from_adjacent");
 
 	/* initialize our sub-operators */
 	BMO_op_initf(
@@ -489,13 +490,22 @@ void bmo_extrude_face_region_exec(BMesh *bm, BMOperator *op)
 			continue;
 		}
 
-		/* orient loop to give same normal as a loop of newedge
-		 * if it exists (will be an extruded face),
-		 * else same normal as a loop of e, if it exists */
-		const bool edge_normal_flip = !(
-		        e_new->l ?
-		        (e_new->l->v == e_new->v1) :
-		        (!e->l || !(e->l->v == e->v1)));
+		bool edge_normal_flip;
+		if (use_normal_from_adjacent == false) {
+			/* Orient loop to give same normal as a loop of 'e_new'
+			 * if it exists (will be one of the faces from the region),
+			 * else same normal as a loop of e, if it exists. */
+			edge_normal_flip = !(
+			        e_new->l ?
+			        (e_new->l->v == e_new->v1) :
+			        (!e->l || !(e->l->v == e->v1)));
+		}
+		else {
+			/* Special case, needed for repetitive extrusions
+			 * that use the normals from the previously created faces. */
+			edge_normal_flip = !(e->l && e->v1 != e->l->v);
+		}
+
 		if (edge_normal_flip == use_normal_flip) {
 			f_verts[0] = e->v1;
 			f_verts[1] = e->v2;



More information about the Bf-blender-cvs mailing list