Fix T91320: Support flipping sides in mesh bisect

Changing active side was introduced in {rB7ff6bfd1e0af} but was never
working for tools/operators other than the sculpt line mask tool.

While for most tools/operators this actually does not make sense, the
bisect tool/operator can actually benefit from it.

thx @campbellbarton for additional input!

Maniphest Tasks: T91320

Differential Revision: https://developer.blender.org/D12473
This commit is contained in:
Philipp Oeser 2021-09-13 15:56:53 +02:00
parent 503d79cd77
commit 1bcdd1c54e
Notes: blender-bot 2023-02-14 05:01:20 +01:00
Referenced by issue #91320, Bisect straight line gesture features dont work ("Flip" / "Snap" option)
2 changed files with 18 additions and 2 deletions

View File

@ -88,6 +88,7 @@ static void mesh_bisect_interactive_calc(bContext *C,
int y_start = RNA_int_get(op->ptr, "ystart");
int x_end = RNA_int_get(op->ptr, "xend");
int y_end = RNA_int_get(op->ptr, "yend");
const bool use_flip = RNA_boolean_get(op->ptr, "flip");
/* reference location (some point in front of the view) for finding a point on a plane */
const float *co_ref = rv3d->ofs;
@ -105,6 +106,9 @@ static void mesh_bisect_interactive_calc(bContext *C,
/* cross both to get a normal */
cross_v3_v3v3(plane_no, co_a, co_b);
normalize_v3(plane_no); /* not needed but nicer for user */
if (use_flip) {
negate_v3(plane_no);
}
/* point on plane, can use either start or endpoint */
ED_view3d_win_to_3d(v3d, region, co_ref, co_a_ss, plane_co);
@ -140,7 +144,18 @@ static int mesh_bisect_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_CANCELLED;
}
int ret = WM_gesture_straightline_invoke(C, op, event);
/* Support flipping if side matters. */
int ret;
const bool clear_inner = RNA_boolean_get(op->ptr, "clear_inner");
const bool clear_outer = RNA_boolean_get(op->ptr, "clear_outer");
const bool use_fill = RNA_boolean_get(op->ptr, "use_fill");
if ((clear_inner != clear_outer) || use_fill) {
ret = WM_gesture_straightline_active_side_invoke(C, op, event);
}
else {
ret = WM_gesture_straightline_invoke(C, op, event);
}
if (ret & OPERATOR_RUNNING_MODAL) {
View3D *v3d = CTX_wm_view3d(C);

View File

@ -954,8 +954,9 @@ int WM_gesture_straightline_modal(bContext *C, wmOperator *op, const wmEvent *ev
break;
}
case GESTURE_MODAL_FLIP: {
/* Toggle snapping on/off. */
/* Toggle flipping on/off. */
gesture->use_flip = !gesture->use_flip;
gesture_straightline_apply(C, op);
break;
}
case GESTURE_MODAL_SELECT: {