Fix T81069: Can't lock axis with move anymore, using Shift+MMB

This fixes and reverts commit c7287ffaec

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.
This commit is contained in:
Germano Cavalcante 2020-09-23 10:45:47 -03:00
parent 4e8d3123f0
commit ba014586a0
Notes: blender-bot 2023-02-14 05:44:22 +01:00
Referenced by issue #82423, Transform Modal Map - double entry Automatic Constraint
Referenced by issue #81069, Can`t lock axis with move anymore, using Shift+MMB
Referenced by issue #80396, Potential candidates for corrective releases
5 changed files with 36 additions and 10 deletions

View File

@ -5011,7 +5011,7 @@ def km_transform_modal_map(_params):
("AUTOIK_CHAIN_LEN_DOWN", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True}, None),
("INSERTOFS_TOGGLE_DIR", {"type": 'T', "value": 'PRESS', "repeat": False}, None),
("AUTOCONSTRAIN", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "repeat": False}, None),
("AUTOCONSTRAIN", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "repeat": False, "shift": True}, None),
("AUTOCONSTRAINPLANE", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "repeat": False, "shift": True}, None),
])
return keymap

View File

@ -3936,7 +3936,7 @@ def km_transform_modal_map(_params):
("AUTOIK_CHAIN_LEN_DOWN", {"type": 'WHEELUPMOUSE', "value": 'PRESS', "shift": True}, None),
("INSERTOFS_TOGGLE_DIR", {"type": 'T', "value": 'PRESS'}, None),
("AUTOCONSTRAIN", {"type": 'MIDDLEMOUSE', "value": 'PRESS'}, None),
("AUTOCONSTRAIN", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None),
("AUTOCONSTRAINPLANE", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None),
])
return keymap

View File

@ -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);

View File

@ -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,

View File

@ -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);
}
}
}