[Bf-blender-cvs] [ba014586a0b] master: Fix T81069: Can't lock axis with move anymore, using Shift+MMB

Germano Cavalcante noreply at git.blender.org
Wed Sep 23 15:46:50 CEST 2020


Commit: ba014586a0bb21792b10ea96948b1f40a135b263
Author: Germano Cavalcante
Date:   Wed Sep 23 10:45:47 2020 -0300
Branches: master
https://developer.blender.org/rBba014586a0bb21792b10ea96948b1f40a135b263

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.

===================================================================

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
M	source/blender/editors/transform/transform.h
M	source/blender/editors/transform/transform_constraints.c

===================================================================

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index bb428cc8cba..c68cc016fc5 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -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
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 bb921565374..c462ac55c53 100644
--- a/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
+++ b/release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
@@ -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
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);
+    }
   }
 }



More information about the Bf-blender-cvs mailing list