diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2020-09-23 16:45:47 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2020-09-23 16:45:56 +0300 |
commit | ba014586a0bb21792b10ea96948b1f40a135b263 (patch) | |
tree | cc74eb8843c201a89d30fb7888374f070f9023ff /source/blender | |
parent | 4e8d3123f016caba8eb382b25b75b70e4ec86203 (diff) |
Fix T81069: Can't lock axis with move anymore, using Shift+MMB
This fixes and reverts commit c7287ffaec59cecd4b63b4bb2ea1aaf44f09f704
Due to hardcodded keys, the modifier for auto contrain plane did not
work with custom keymaps and was in conflict with other keyitems.
Its usability is also confusing since it cannot be used without
`MOD_PRECISION`
But instead of removing it, it is better to make this modifier compatible
with custom keymaps and keep the conflict.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/transform/transform.c | 10 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.h | 2 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_constraints.c | 30 |
3 files changed, 34 insertions, 8 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 01fdb267108..b3619f16b01 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -683,6 +683,7 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) {TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""}, {TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""}, {TFM_MODAL_AUTOCONSTRAINT, "AUTOCONSTRAIN", 0, "Automatic Constraint", ""}, + {TFM_MODAL_AUTOCONSTRAINTPLANE, "AUTOCONSTRAINPLANE", 0, "Automatic Constraint", ""}, {0, NULL, 0, NULL, NULL}, }; @@ -703,6 +704,8 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) * WM_modalkeymap_add_item(keymap, EVT_RKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_ROTATE); * WM_modalkeymap_add_item(keymap, EVT_SKEY, KM_PRESS, KM_ANY, 0, TFM_MODAL_RESIZE); * WM_modalkeymap_add_item(keymap, MIDDLEMOUSE, KM_PRESS, KM_ANY, 0, TFM_MODAL_AUTOCONSTRAINT); + * WM_modalkeymap_add_item( + * keymap, MIDDLEMOUSE, KM_PRESS, KM_SHIFT, 0, TFM_MODAL_AUTOCONSTRAINTPLANE); * \endcode */ @@ -794,7 +797,7 @@ int transformEvent(TransInfo *t, const wmEvent *event) handled = true; } else if (event->type == MOUSEMOVE) { - if (t->modifiers & MOD_CONSTRAINT_SELECT) { + if (t->modifiers & (MOD_CONSTRAINT_SELECT | MOD_CONSTRAINT_PLANE)) { t->con.mode |= CON_SELECT; } @@ -1077,6 +1080,7 @@ int transformEvent(TransInfo *t, const wmEvent *event) } break; case TFM_MODAL_AUTOCONSTRAINT: + case TFM_MODAL_AUTOCONSTRAINTPLANE: if ((t->flag & T_NO_CONSTRAINT) == 0) { /* exception for switching to dolly, or trackball, in camera view */ if (t->flag & T_CAMERA) { @@ -1089,7 +1093,8 @@ int transformEvent(TransInfo *t, const wmEvent *event) } } else { - t->modifiers |= MOD_CONSTRAINT_SELECT; + t->modifiers |= (event->val == TFM_MODAL_AUTOCONSTRAINT) ? MOD_CONSTRAINT_SELECT : + MOD_CONSTRAINT_PLANE; if (t->con.mode & CON_APPLY) { stopConstraint(t); } @@ -1201,6 +1206,7 @@ int transformEvent(TransInfo *t, const wmEvent *event) /* Disable modifiers. */ int modifiers = t->modifiers; modifiers &= ~MOD_CONSTRAINT_SELECT; + modifiers &= ~MOD_CONSTRAINT_PLANE; if (modifiers != t->modifiers) { if (t->modifiers & MOD_CONSTRAINT_SELECT) { postSelectConstraint(t); diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index ef206973e3b..0c4aae9e2d1 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -497,6 +497,7 @@ enum { MOD_PRECISION = 1 << 1, MOD_SNAP = 1 << 2, MOD_SNAP_INVERT = 1 << 3, + MOD_CONSTRAINT_PLANE = 1 << 4, }; /* use node center for transform instead of upper-left corner. @@ -576,6 +577,7 @@ enum { TFM_MODAL_INSERTOFS_TOGGLE_DIR = 27, TFM_MODAL_AUTOCONSTRAINT = 28, + TFM_MODAL_AUTOCONSTRAINTPLANE = 29, }; bool initTransform(struct bContext *C, diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 68bde912fe5..805411ffc20 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -1036,16 +1036,34 @@ static void setNearestAxis3d(TransInfo *t) } if (len[0] <= len[1] && len[0] <= len[2]) { - t->con.mode |= CON_AXIS0; - BLI_snprintf(t->con.text, sizeof(t->con.text), TIP_(" along %s X axis"), t->spacename); + if (t->modifiers & MOD_CONSTRAINT_PLANE) { + t->con.mode |= (CON_AXIS1 | CON_AXIS2); + BLI_snprintf(t->con.text, sizeof(t->con.text), TIP_(" locking %s X axis"), t->spacename); + } + else { + t->con.mode |= CON_AXIS0; + BLI_snprintf(t->con.text, sizeof(t->con.text), TIP_(" along %s X axis"), t->spacename); + } } else if (len[1] <= len[0] && len[1] <= len[2]) { - t->con.mode |= CON_AXIS1; - BLI_snprintf(t->con.text, sizeof(t->con.text), TIP_(" along %s Y axis"), t->spacename); + if (t->modifiers & MOD_CONSTRAINT_PLANE) { + t->con.mode |= (CON_AXIS0 | CON_AXIS2); + BLI_snprintf(t->con.text, sizeof(t->con.text), TIP_(" locking %s Y axis"), t->spacename); + } + else { + t->con.mode |= CON_AXIS1; + BLI_snprintf(t->con.text, sizeof(t->con.text), TIP_(" along %s Y axis"), t->spacename); + } } else if (len[2] <= len[1] && len[2] <= len[0]) { - t->con.mode |= CON_AXIS2; - BLI_snprintf(t->con.text, sizeof(t->con.text), TIP_(" along %s Z axis"), t->spacename); + if (t->modifiers & MOD_CONSTRAINT_PLANE) { + t->con.mode |= (CON_AXIS0 | CON_AXIS1); + BLI_snprintf(t->con.text, sizeof(t->con.text), TIP_(" locking %s Z axis"), t->spacename); + } + else { + t->con.mode |= CON_AXIS2; + BLI_snprintf(t->con.text, sizeof(t->con.text), TIP_(" along %s Z axis"), t->spacename); + } } } |