[Bf-blender-cvs] [3b4486424a3] master: Fix repeated transform constraint orientations

Germano Cavalcante noreply at git.blender.org
Thu Jan 26 18:54:30 CET 2023


Commit: 3b4486424a3299756dbe7eba923348c83304ca36
Author: Germano Cavalcante
Date:   Thu Jan 26 07:54:04 2023 -0300
Branches: master
https://developer.blender.org/rB3b4486424a3299756dbe7eba923348c83304ca36

Fix repeated transform constraint orientations

On some occasions, as in cases where transform operations are triggered
via gizmos, the constrain orientations that can be toggled with
multiple clicks of X, Y or Z were repeated.

There is no use in maintaining repeated orientations.

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

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

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

diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 61adc98c258..f8e116e77b8 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -1001,6 +1001,9 @@ void postSelectConstraint(TransInfo *t)
 
 static void setNearestAxis2d(TransInfo *t)
 {
+  /* Clear any prior constraint flags. */
+  t->con.mode &= ~(CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
+
   /* no correction needed... just use whichever one is lower */
   if (abs(t->mval[0] - t->con.imval[0]) < abs(t->mval[1] - t->con.imval[1])) {
     t->con.mode |= CON_AXIS1;
@@ -1014,6 +1017,9 @@ static void setNearestAxis2d(TransInfo *t)
 
 static void setNearestAxis3d(TransInfo *t)
 {
+  /* Clear any prior constraint flags. */
+  t->con.mode &= ~(CON_AXIS0 | CON_AXIS1 | CON_AXIS2);
+
   float zfac;
   float mvec[3], proj[3];
   float len[3];
@@ -1090,10 +1096,7 @@ static void setNearestAxis3d(TransInfo *t)
 
 void setNearestAxis(TransInfo *t)
 {
-  /* clear any prior constraint flags */
-  t->con.mode &= ~CON_AXIS0;
-  t->con.mode &= ~CON_AXIS1;
-  t->con.mode &= ~CON_AXIS2;
+  eTConstraint mode_prev = t->con.mode;
 
   /* constraint setting - depends on spacetype */
   if (t->spacetype == SPACE_VIEW3D) {
@@ -1105,7 +1108,9 @@ void setNearestAxis(TransInfo *t)
     setNearestAxis2d(t);
   }
 
-  projection_matrix_calc(t, t->con.pmtx);
+  if (mode_prev != t->con.mode) {
+    projection_matrix_calc(t, t->con.pmtx);
+  }
 }
 
 /** \} */
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 968e2bca5b9..f09c919c8b7 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -440,6 +440,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
 
   {
     short orient_types[3];
+    short orient_type_apply = O_DEFAULT;
     float custom_matrix[3][3];
 
     int orient_type_scene = V3D_ORIENT_GLOBAL;
@@ -502,14 +503,23 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
         t->is_orient_default_overwrite = true;
       }
     }
-    else if (t->con.mode & CON_APPLY) {
-      orient_type_set = orient_type_scene;
-    }
-    else if (orient_type_scene == V3D_ORIENT_GLOBAL) {
-      orient_type_set = V3D_ORIENT_LOCAL;
+
+    if (orient_type_set == -1) {
+      if (orient_type_scene == V3D_ORIENT_GLOBAL) {
+        orient_type_set = V3D_ORIENT_LOCAL;
+      }
+      else {
+        orient_type_set = V3D_ORIENT_GLOBAL;
+      }
+
+      if (t->con.mode & CON_APPLY) {
+        orient_type_apply = O_SCENE;
+      }
     }
     else {
-      orient_type_set = V3D_ORIENT_GLOBAL;
+      if (t->con.mode & CON_APPLY) {
+        orient_type_apply = O_SET;
+      }
     }
 
     BLI_assert(!ELEM(-1, orient_type_default, orient_type_set));
@@ -546,7 +556,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
       }
     }
 
-    transform_orientations_current_set(t, (t->con.mode & CON_APPLY) ? 2 : 0);
+    transform_orientations_current_set(t, orient_type_apply);
   }
 
   if (op && ((prop = RNA_struct_find_property(op->ptr, "release_confirm")) &&



More information about the Bf-blender-cvs mailing list