[Bf-blender-cvs] [0515ff70ec0] master: Transform: Use "orient_matrix" as a default when available

Germano Cavalcante noreply at git.blender.org
Fri Apr 9 23:27:20 CEST 2021


Commit: 0515ff70ec09694d11e36e90212119574c65ada9
Author: Germano Cavalcante
Date:   Fri Apr 9 16:01:53 2021 -0300
Branches: master
https://developer.blender.org/rB0515ff70ec09694d11e36e90212119574c65ada9

Transform: Use "orient_matrix" as a default when available

The "orient_matrix" parameter was only used when contraint was defined.

This change will hardly be noticed by the user, but it can be useful for
addon developers.

Possibly resolves T85734.

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

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

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

diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index e43a3ff3635..c0c4b22da98 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -409,9 +409,10 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
     short orient_types[3];
     float custom_matrix[3][3];
 
-    short orient_type_scene = V3D_ORIENT_GLOBAL;
-    short orient_type_set = V3D_ORIENT_GLOBAL;
-    short orient_type_matrix_set = -1;
+    int orient_type_scene = V3D_ORIENT_GLOBAL;
+    int orient_type_default = -1;
+    int orient_type_set = -1;
+    int orient_type_matrix_set = -1;
 
     bool use_orient_axis = false;
 
@@ -424,7 +425,13 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
       }
     }
 
-    short orient_type_default = orient_type_scene;
+    if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_type")) &&
+               RNA_property_is_set(op->ptr, prop))) {
+      orient_type_set = RNA_property_enum_get(op->ptr, prop);
+      if (orient_type_set >= V3D_ORIENT_CUSTOM + BIF_countTransformOrientation(C)) {
+        orient_type_set = V3D_ORIENT_GLOBAL;
+      }
+    }
 
     if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis"))) {
       t->orient_axis = RNA_property_enum_get(op->ptr, prop);
@@ -435,52 +442,54 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
       t->orient_axis_ortho = RNA_property_enum_get(op->ptr, prop);
     }
 
-    if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_type")) &&
+    if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_matrix")) &&
                RNA_property_is_set(op->ptr, prop))) {
-      orient_type_set = RNA_property_enum_get(op->ptr, prop);
-      if (orient_type_set >= V3D_ORIENT_CUSTOM + BIF_countTransformOrientation(C)) {
-        orient_type_set = V3D_ORIENT_GLOBAL;
+      RNA_property_float_get_array(op->ptr, prop, &custom_matrix[0][0]);
+
+      if ((prop = RNA_struct_find_property(op->ptr, "orient_matrix_type")) &&
+          RNA_property_is_set(op->ptr, prop)) {
+        orient_type_matrix_set = RNA_property_enum_get(op->ptr, prop);
+      }
+      else if (orient_type_set == -1) {
+        orient_type_set = V3D_ORIENT_CUSTOM_MATRIX;
       }
+    }
 
-      /* Change the default orientation to be used when redoing. */
+    if (orient_type_set != -1) {
       orient_type_default = orient_type_set;
     }
+    else if (orient_type_matrix_set != -1) {
+      orient_type_default = orient_type_set = orient_type_matrix_set;
+    }
     else if (t->con.mode & CON_APPLY) {
-      orient_type_set = orient_type_scene;
+      orient_type_default = orient_type_set = orient_type_scene;
     }
     else {
-      if (orient_type_set == orient_type_scene) {
-        BLI_assert(orient_type_set == V3D_ORIENT_GLOBAL);
+      if (orient_type_scene == V3D_ORIENT_GLOBAL) {
         orient_type_set = V3D_ORIENT_LOCAL;
       }
+      else {
+        orient_type_set = V3D_ORIENT_GLOBAL;
+      }
 
       if ((t->flag & T_MODAL) && (use_orient_axis || transform_mode_is_changeable(t->mode)) &&
           (t->mode != TFM_ALIGN)) {
         orient_type_default = V3D_ORIENT_VIEW;
       }
-    }
-
-    if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_matrix")) &&
-               RNA_property_is_set(op->ptr, prop))) {
-      RNA_property_float_get_array(op->ptr, prop, &custom_matrix[0][0]);
-
-      if ((prop = RNA_struct_find_property(op->ptr, "orient_matrix_type")) &&
-          RNA_property_is_set(op->ptr, prop)) {
-        orient_type_matrix_set = RNA_property_enum_get(op->ptr, prop);
-      }
       else {
-        orient_type_matrix_set = orient_type_set;
+        orient_type_default = orient_type_scene;
       }
+    }
 
-      if (orient_type_matrix_set == orient_type_set) {
-        /* Constraints are forced to use the custom matrix when redoing. */
-        orient_type_set = V3D_ORIENT_CUSTOM_MATRIX;
-      }
+    BLI_assert(!ELEM(-1, orient_type_default, orient_type_set));
+    if (orient_type_matrix_set == orient_type_set) {
+      /* Constraints are forced to use the custom matrix when redoing. */
+      orient_type_set = V3D_ORIENT_CUSTOM_MATRIX;
     }
 
-    orient_types[0] = orient_type_default;
-    orient_types[1] = orient_type_scene;
-    orient_types[2] = orient_type_set;
+    orient_types[0] = (short)orient_type_default;
+    orient_types[1] = (short)orient_type_scene;
+    orient_types[2] = (short)orient_type_set;
 
     for (int i = 0; i < 3; i++) {
       /* For efficiency, avoid calculating the same orientation twice. */



More information about the Bf-blender-cvs mailing list