[Bf-blender-cvs] [2265104f0b1] blender-v2.93-release: Fix (unreported): Automatic transform contraint not being disabled

Germano Cavalcante noreply at git.blender.org
Mon May 24 17:29:48 CEST 2021


Commit: 2265104f0b14fa0d6693d881d7e8c1b8c2aa755b
Author: Germano Cavalcante
Date:   Mon May 24 11:30:44 2021 -0300
Branches: blender-v2.93-release
https://developer.blender.org/rB2265104f0b14fa0d6693d881d7e8c1b8c2aa755b

Fix (unreported): Automatic transform contraint not being disabled

It does not make sense to maintain automatic constraint selection when
you manually set the 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 fb3b2aa790b..5fc27a8b434 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -724,81 +724,92 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf)
 
 static bool transform_event_modal_constraint(TransInfo *t, short modal_type)
 {
-  if (!(t->flag & T_NO_CONSTRAINT)) {
-    if (t->flag & T_2D_EDIT && ELEM(modal_type, TFM_MODAL_AXIS_Z, TFM_MODAL_PLANE_Z)) {
+  if (t->flag & T_NO_CONSTRAINT) {
+    return false;
+  }
+
+  if (t->flag & T_2D_EDIT && ELEM(modal_type, TFM_MODAL_AXIS_Z, TFM_MODAL_PLANE_Z)) {
+    return false;
+  }
+
+  int constraint_curr = -1;
+
+  if (t->modifiers & (MOD_CONSTRAINT_SELECT_AXIS | MOD_CONSTRAINT_SELECT_PLANE)) {
+    t->modifiers &= ~(MOD_CONSTRAINT_SELECT_AXIS | MOD_CONSTRAINT_SELECT_PLANE);
+
+    /* Avoid changing orientation in this case. */
+    constraint_curr = -2;
+  }
+  else if (t->con.mode & CON_APPLY) {
+    constraint_curr = t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
+  }
+
+  int constraint_new;
+  const char *msg_2d = "", *msg_3d = "";
+
+  /* Initialize */
+  switch (modal_type) {
+    case TFM_MODAL_AXIS_X:
+      msg_2d = TIP_("along X");
+      msg_3d = TIP_("along %s X");
+      constraint_new = CON_AXIS0;
+      break;
+    case TFM_MODAL_AXIS_Y:
+      msg_2d = TIP_("along Y");
+      msg_3d = TIP_("along %s Y");
+      constraint_new = CON_AXIS1;
+      break;
+    case TFM_MODAL_AXIS_Z:
+      msg_2d = TIP_("along Z");
+      msg_3d = TIP_("along %s Z");
+      constraint_new = CON_AXIS2;
+      break;
+    case TFM_MODAL_PLANE_X:
+      msg_3d = TIP_("locking %s X");
+      constraint_new = CON_AXIS1 | CON_AXIS2;
+      break;
+    case TFM_MODAL_PLANE_Y:
+      msg_3d = TIP_("locking %s Y");
+      constraint_new = CON_AXIS0 | CON_AXIS2;
+      break;
+    case TFM_MODAL_PLANE_Z:
+      msg_3d = TIP_("locking %s Z");
+      constraint_new = CON_AXIS0 | CON_AXIS1;
+      break;
+    default:
+      /* Invalid key */
       return false;
-    }
-    int constraint_curr = (t->con.mode & CON_APPLY) ?
-                              t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2) :
-                              -1;
-    int constraint_new;
-    const char *msg_2d = "", *msg_3d = "";
+  }
 
-    /* Initialize */
-    switch (modal_type) {
-      case TFM_MODAL_AXIS_X:
-        msg_2d = TIP_("along X");
-        msg_3d = TIP_("along %s X");
-        constraint_new = CON_AXIS0;
-        break;
-      case TFM_MODAL_AXIS_Y:
-        msg_2d = TIP_("along Y");
-        msg_3d = TIP_("along %s Y");
-        constraint_new = CON_AXIS1;
-        break;
-      case TFM_MODAL_AXIS_Z:
-        msg_2d = TIP_("along Z");
-        msg_3d = TIP_("along %s Z");
-        constraint_new = CON_AXIS2;
-        break;
-      case TFM_MODAL_PLANE_X:
-        msg_3d = TIP_("locking %s X");
-        constraint_new = CON_AXIS1 | CON_AXIS2;
-        break;
-      case TFM_MODAL_PLANE_Y:
-        msg_3d = TIP_("locking %s Y");
-        constraint_new = CON_AXIS0 | CON_AXIS2;
-        break;
-      case TFM_MODAL_PLANE_Z:
-        msg_3d = TIP_("locking %s Z");
-        constraint_new = CON_AXIS0 | CON_AXIS1;
-        break;
-      default:
-        /* Invalid key */
-        return false;
+  if (t->flag & T_2D_EDIT) {
+    BLI_assert(modal_type < TFM_MODAL_PLANE_X);
+    if (constraint_new == CON_AXIS2) {
+      return false;
     }
-
-    if (t->flag & T_2D_EDIT) {
-      BLI_assert(modal_type < TFM_MODAL_PLANE_X);
-      if (constraint_new == CON_AXIS2) {
-        return false;
-      }
-      if (constraint_curr == constraint_new) {
-        stopConstraint(t);
-      }
-      else {
-        setUserConstraint(t, constraint_new, msg_2d);
-      }
+    if (constraint_curr == constraint_new) {
+      stopConstraint(t);
     }
     else {
-      short orient_index = 1;
-      if (t->orient_curr == O_DEFAULT || ELEM(constraint_curr, -1, constraint_new)) {
-        /* Successive presses on existing axis, cycle orientation modes. */
-        orient_index = (short)((t->orient_curr + 1) % (int)ARRAY_SIZE(t->orient));
-      }
+      setUserConstraint(t, constraint_new, msg_2d);
+    }
+  }
+  else {
+    short orient_index = 1;
+    if (t->orient_curr == O_DEFAULT || ELEM(constraint_curr, -1, constraint_new)) {
+      /* Successive presses on existing axis, cycle orientation modes. */
+      orient_index = (short)((t->orient_curr + 1) % (int)ARRAY_SIZE(t->orient));
+    }
 
-      transform_orientations_current_set(t, orient_index);
-      if (orient_index == 0) {
-        stopConstraint(t);
-      }
-      else {
-        setUserConstraint(t, constraint_new, msg_3d);
-      }
+    transform_orientations_current_set(t, orient_index);
+    if (orient_index == 0) {
+      stopConstraint(t);
+    }
+    else {
+      setUserConstraint(t, constraint_new, msg_3d);
     }
-    t->redraw |= TREDRAW_HARD;
-    return true;
   }
-  return false;
+  t->redraw |= TREDRAW_HARD;
+  return true;
 }
 
 int transformEvent(TransInfo *t, const wmEvent *event)
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 7d04086e20d..8c74d5349ba 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -975,7 +975,6 @@ void initSelectConstraint(TransInfo *t)
   }
 
   setUserConstraint(t, CON_APPLY | CON_SELECT, "%s");
-  setNearestAxis(t);
 }
 
 void selectConstraint(TransInfo *t)



More information about the Bf-blender-cvs mailing list