[Bf-blender-cvs] [9add12ff05c] master: Transform: Improve event detection for AutoConstrain
Germano Cavalcante
noreply at git.blender.org
Thu Nov 26 17:44:00 CET 2020
Commit: 9add12ff05c9bbc8332b8d69d4f14193dd8409bf
Author: Germano Cavalcante
Date: Thu Nov 26 13:42:48 2020 -0300
Branches: master
https://developer.blender.org/rB9add12ff05c9bbc8332b8d69d4f14193dd8409bf
Transform: Improve event detection for AutoConstrain
The event "value" is not really required since this operation works as a toogle.
This change cleans and simplifies the code.
===================================================================
M release/scripts/presets/keyconfig/keymap_data/blender_default.py
M release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
M source/blender/editors/transform/transform.c
===================================================================
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index d66d7c45dd4..20755fcf856 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -5037,8 +5037,8 @@ def km_transform_modal_map(_params):
("AUTOIK_CHAIN_LEN_UP", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True}, None),
("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),
- ("AUTOCONSTRAINPLANE", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None),
+ ("AUTOCONSTRAIN", {"type": 'MIDDLEMOUSE', "value": 'ANY'}, None),
+ ("AUTOCONSTRAINPLANE", {"type": 'MIDDLEMOUSE', "value": 'ANY', "shift": True}, None),
])
return keymap
diff --git a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
index c79a59145cf..d1a595f04c8 100644
--- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
+++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
@@ -3942,8 +3942,8 @@ def km_transform_modal_map(_params):
("AUTOIK_CHAIN_LEN_UP", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "shift": True}, None),
("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),
- ("AUTOCONSTRAINPLANE", {"type": 'MIDDLEMOUSE', "value": 'PRESS', "shift": True}, None),
+ ("AUTOCONSTRAIN", {"type": 'MIDDLEMOUSE', "value": 'ANY'}, None),
+ ("AUTOCONSTRAINPLANE", {"type": 'MIDDLEMOUSE', "value": 'ANY', "shift": True}, None),
])
return keymap
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 817b980fa24..bba0b750d0c 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1083,25 +1083,32 @@ int transformEvent(TransInfo *t, const wmEvent *event)
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) {
- if (t->mode == TFM_TRANSLATION) {
- setLocalConstraint(t, (CON_AXIS2), TIP_("along local Z"));
- }
- else if (t->mode == TFM_ROTATION) {
- restoreTransObjects(t);
- transform_mode_init(t, NULL, TFM_TRACKBALL);
- }
+ if (t->modifiers & (MOD_CONSTRAINT_SELECT | MOD_CONSTRAINT_PLANE)) {
+ /* Confirm. */
+ postSelectConstraint(t);
+ t->modifiers &= ~(MOD_CONSTRAINT_SELECT | MOD_CONSTRAINT_PLANE);
}
else {
- t->modifiers |= (event->val == TFM_MODAL_AUTOCONSTRAINT) ? MOD_CONSTRAINT_SELECT :
- MOD_CONSTRAINT_PLANE;
- if (t->con.mode & CON_APPLY) {
- stopConstraint(t);
+ if (t->flag & T_CAMERA) {
+ /* Exception for switching to dolly, or trackball, in camera view. */
+ if (t->mode == TFM_TRANSLATION) {
+ setLocalConstraint(t, (CON_AXIS2), TIP_("along local Z"));
+ }
+ else if (t->mode == TFM_ROTATION) {
+ restoreTransObjects(t);
+ transform_mode_init(t, NULL, TFM_TRACKBALL);
+ }
}
else {
- initSelectConstraint(t);
- postSelectConstraint(t);
+ t->modifiers |= (event->val == TFM_MODAL_AUTOCONSTRAINT) ? MOD_CONSTRAINT_SELECT :
+ MOD_CONSTRAINT_PLANE;
+ if (t->con.mode & CON_APPLY) {
+ stopConstraint(t);
+ }
+ else {
+ initSelectConstraint(t);
+ postSelectConstraint(t);
+ }
}
}
t->redraw |= TREDRAW_HARD;
@@ -1203,38 +1210,6 @@ int transformEvent(TransInfo *t, const wmEvent *event)
handled = true;
}
break;
- case EVENT_NONE:
- case INBETWEEN_MOUSEMOVE:
- case INPUTCHANGE:
- case WINDEACTIVATE:
- case TIMER:
- case TIMERJOBS:
- case TIMERAUTOSAVE:
- case TIMERREPORT:
- case TIMERREGION:
- case TIMERNOTIFIER:
- case TIMERF:
- /* Although rare, prevent these events from affecting the state of the modifiers. */
- break;
- default: {
- if (event->type == t->launch_event) {
- /* The user can hold the launch button and release it here. */
- break;
- }
- /* Disable modifiers. */
- int modifiers = t->modifiers;
- modifiers &= ~MOD_CONSTRAINT_SELECT;
- modifiers &= ~MOD_CONSTRAINT_PLANE;
- if (modifiers != t->modifiers) {
- if (t->modifiers & (MOD_CONSTRAINT_SELECT | MOD_CONSTRAINT_PLANE)) {
- postSelectConstraint(t);
- }
- t->modifiers = modifiers;
- t->redraw |= TREDRAW_HARD;
- handled = true;
- }
- break;
- }
}
/* confirm transform if launch key is released after mouse move */
More information about the Bf-blender-cvs
mailing list