From fc854fc252b0baa91016392c8aa59c7e494f3203 Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Thu, 25 May 2023 11:34:25 -0300 Subject: [PATCH] Transform: remove precision modification upon starting navigation In order to execute the navigation of type "VIEW3D_OT_move," the user is required to press both the `Shift` and `MMB` keys. However, pressing `Shift` also activates the precision modifier for the transform. Consequently, while the `MMB` is unpressed, the transform operation unintentionally remains in precision mode, altering the mouse position. To address this issue, the solution was to eliminate the precision changes immediately after the navigation is initiated. Unfortunately, we have no way of knowing whether the user actually unintentionally enabled precision, so this solution serves as a workaround. Ideally, keymap conflicts should be avoided. --- source/blender/editors/transform/transform.h | 1 + source/blender/editors/transform/transform_input.c | 14 ++++++++++++++ source/blender/editors/transform/transform_ops.c | 5 +++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index c49e8338e12..6bf11d4d4da 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -768,6 +768,7 @@ void applyMouseInput(struct TransInfo *t, const int mval[2], float output[3]); void transform_input_update(TransInfo *t, const float fac); +void transform_input_virtual_mval_reset(TransInfo *t); void setCustomPoints(TransInfo *t, MouseInput *mi, const int start[2], const int end[2]); void setCustomPointsFromDirection(TransInfo *t, MouseInput *mi, const float dir[2]); diff --git a/source/blender/editors/transform/transform_input.c b/source/blender/editors/transform/transform_input.c index bba57ff9602..088240055a7 100644 --- a/source/blender/editors/transform/transform_input.c +++ b/source/blender/editors/transform/transform_input.c @@ -494,4 +494,18 @@ void transform_input_update(TransInfo *t, const float fac) } } +void transform_input_virtual_mval_reset(TransInfo *t) +{ + MouseInput *mi = &t->mouse; + if (ELEM(mi->apply, InputAngle, InputAngleSpring)) { + struct InputAngle_Data *data = mi->data; + data->angle = 0.0; + data->mval_prev[0] = mi->imval[0]; + data->mval_prev[1] = mi->imval[1]; + } + else { + memset(&mi->virtual_mval, 0, sizeof(mi->virtual_mval)); + } +} + /** \} */ diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index b501649a614..881dbabb385 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -428,9 +428,10 @@ static int transform_modal(bContext *C, wmOperator *op, const wmEvent *event) } if (t->modifiers & MOD_PRECISION) { - /* Remove Precision modifier, it may have be unintentionally enabled. */ + /* WORKAROUND: Remove precision modification, it may have be unintentionally enabled. */ t->modifiers &= ~MOD_PRECISION; - t->mouse.precision = 0; + t->mouse.precision = false; + transform_input_virtual_mval_reset(t); } /* Make sure `t->mval` is up to date before calling #transformViewUpdate. */