diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2021-09-13 16:56:53 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2021-09-13 17:42:27 +0300 |
commit | 1bcdd1c54e6e9034af2ad1d78b30b891ac42a655 (patch) | |
tree | d5cdc3079b98e718f93c832060433943affb1fa0 /source | |
parent | 503d79cd779f103cbea74eca390419e8c6fd2aad (diff) |
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
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/mesh/editmesh_bisect.c | 17 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_gesture_ops.c | 3 |
2 files changed, 18 insertions, 2 deletions
diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c index 3c8afe8e7db..9f6968542a2 100644 --- a/source/blender/editors/mesh/editmesh_bisect.c +++ b/source/blender/editors/mesh/editmesh_bisect.c @@ -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); diff --git a/source/blender/windowmanager/intern/wm_gesture_ops.c b/source/blender/windowmanager/intern/wm_gesture_ops.c index 0177e336121..788e4214ac7 100644 --- a/source/blender/windowmanager/intern/wm_gesture_ops.c +++ b/source/blender/windowmanager/intern/wm_gesture_ops.c @@ -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: { |