[Bf-blender-cvs] [21e72496a62] master: Fix T96728: 'Automatic Constraint' using the wrong orientation

Germano Cavalcante noreply at git.blender.org
Mon Mar 28 19:23:31 CEST 2022


Commit: 21e72496a6297a1cee4fcb77f3efa24b7ee3c418
Author: Germano Cavalcante
Date:   Mon Mar 28 14:21:33 2022 -0300
Branches: master
https://developer.blender.org/rB21e72496a6297a1cee4fcb77f3efa24b7ee3c418

Fix T96728: 'Automatic Constraint' using the wrong orientation

If the `Automatic Constraint` modifier was activated while an axis
constraint was already set, the orientation used would be the default
orientation of the mode and not that of the scene.

This was because the `initSelectConstraint` function was not called in
this case and the `Automatic Constraint` mode was enabled by other
indirect means.

So the solution is to call `initSelectConstraint` in either case and
remove these "indirect means" of enabling `Automatic Constraint`.

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

M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform_constraints.c

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

diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index ec15b748c40..76d42fae444 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -843,10 +843,6 @@ int transformEvent(TransInfo *t, const wmEvent *event)
     handled = true;
   }
   else if (event->type == MOUSEMOVE) {
-    if (t->modifiers & (MOD_CONSTRAINT_SELECT_AXIS | MOD_CONSTRAINT_SELECT_PLANE)) {
-      t->con.mode |= CON_SELECT;
-    }
-
     copy_v2_v2_int(t->mval, event->mval);
 
     /* Use this for soft redraw. Might cause flicker in object mode */
@@ -1095,6 +1091,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
             /* Confirm. */
             postSelectConstraint(t);
             t->modifiers &= ~(MOD_CONSTRAINT_SELECT_AXIS | MOD_CONSTRAINT_SELECT_PLANE);
+            t->redraw = TREDRAW_HARD;
           }
           else {
             if (t->options & CTX_CAMERA) {
@@ -1106,6 +1103,7 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                 restoreTransObjects(t);
                 transform_mode_init(t, NULL, TFM_TRACKBALL);
               }
+              t->redraw = TREDRAW_HARD;
             }
             else {
               t->modifiers |= (event->val == TFM_MODAL_AUTOCONSTRAINT) ?
@@ -1114,13 +1112,13 @@ int transformEvent(TransInfo *t, const wmEvent *event)
               if (t->con.mode & CON_APPLY) {
                 stopConstraint(t);
               }
-              else {
-                initSelectConstraint(t);
-                postSelectConstraint(t);
-              }
+
+              initSelectConstraint(t);
+              /* Use #TREDRAW_SOFT so that #selectConstraint is only called on the next event.
+               * This allows us to "deselect" the contraint. */
+              t->redraw = TREDRAW_SOFT;
             }
           }
-          t->redraw |= TREDRAW_HARD;
           handled = true;
         }
         break;
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 81b35e4539b..0bb00032561 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -996,19 +996,10 @@ void selectConstraint(TransInfo *t)
 
 void postSelectConstraint(TransInfo *t)
 {
-  if (!(t->con.mode & CON_SELECT)) {
-    return;
-  }
-
-  t->con.mode &= ~CON_AXIS0;
-  t->con.mode &= ~CON_AXIS1;
-  t->con.mode &= ~CON_AXIS2;
   t->con.mode &= ~CON_SELECT;
-
-  setNearestAxis(t);
-
-  startConstraint(t);
-  t->redraw = TREDRAW_HARD;
+  if (!(t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2))) {
+    t->con.mode &= ~CON_APPLY;
+  }
 }
 
 static void setNearestAxis2d(TransInfo *t)



More information about the Bf-blender-cvs mailing list