Fix T60099: Inconsistent normals from spin tool

This commit is contained in:
Campbell Barton
2019-01-04 16:23:04 +11:00
parent 3f0a26137a
commit 3ffce6a130
3 changed files with 21 additions and 9 deletions

View File

@@ -1040,6 +1040,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'}},
},

View File

@@ -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,

View File

@@ -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;