Gizmo: support spin tool normal flipping

Use the 2x spin tool has 2x handles to control normal direction,
dragging either handle backwards now reverses normals.

Previously it was common for the spin result to have normals
flipped the wrong way.
This commit is contained in:
Campbell Barton 2018-09-25 14:15:12 +10:00
parent a7bf4966e2
commit ebdeb3eca0
2 changed files with 11 additions and 4 deletions

View File

@ -70,8 +70,8 @@ static int edbm_spin_exec(bContext *C, wmOperator *op)
RNA_float_get_array(op->ptr, "center", cent);
RNA_float_get_array(op->ptr, "axis", axis);
const int steps = RNA_int_get(op->ptr, "steps");
const float angle = -RNA_float_get(op->ptr, "angle");
const bool use_normal_flip = RNA_boolean_get(op->ptr, "use_normal_flip");
const float angle = RNA_float_get(op->ptr, "angle");
const bool use_normal_flip = RNA_boolean_get(op->ptr, "use_normal_flip") ^ (angle < 0.0f);
const bool dupli = RNA_boolean_get(op->ptr, "dupli");
if (is_zero_v3(axis)) {
@ -93,7 +93,7 @@ static int edbm_spin_exec(bContext *C, wmOperator *op)
em, &spinop, op,
"spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f space=%m4 "
"use_normal_flip=%b use_duplicate=%b",
BM_ELEM_SELECT, cent, axis, d, steps, angle, obedit->obmat, use_normal_flip, dupli))
BM_ELEM_SELECT, cent, axis, d, steps, -angle, obedit->obmat, use_normal_flip, dupli))
{
continue;
}

View File

@ -197,7 +197,14 @@ static void gizmo_mesh_spin_init_refresh_axis_orientation(
for (int j = 0; j < 2; j++) {
gz = ggd->gizmos.icon_button[axis_index][j];
PointerRNA *ptr = WM_gizmo_operator_set(gz, 0, ggd->data.ot_spin, NULL);
RNA_float_set_array(ptr, "axis", axis_vec);
float axis_vec_flip[3];
if (0 == j) {
negate_v3_v3(axis_vec_flip, axis_vec);
}
else {
copy_v3_v3(axis_vec_flip, axis_vec);
}
RNA_float_set_array(ptr, "axis", axis_vec_flip);
}
}
}