[Bf-blender-cvs] [b5eeef834f5] master: Fix direction of the Gizmo Extrude adjustment axis

Germano Cavalcante noreply at git.blender.org
Thu May 7 21:52:38 CEST 2020


Commit: b5eeef834f5d59c081ff15a5b8a01d414c6d8e1d
Author: Germano Cavalcante
Date:   Thu May 7 16:51:30 2020 -0300
Branches: master
https://developer.blender.org/rBb5eeef834f5d59c081ff15a5b8a01d414c6d8e1d

Fix direction of the Gizmo Extrude adjustment axis

The extrude adjustment gizmo reads the last constrained axis set.
So it is important to keep the final value actually used.

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

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

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

diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index c15c8aefddf..6ff3826da09 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1740,38 +1740,26 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
          !RNA_property_is_set(op->ptr, prop))) {
       /* Set the first time to register on redo. */
       RNA_property_enum_set(op->ptr, prop, orient_set);
-
-      if (((prop = RNA_struct_find_property(op->ptr, "orient_matrix")) &&
-           !RNA_property_is_set(op->ptr, prop))) {
-        RNA_float_set_array(op->ptr, "orient_matrix", &t->spacemtx[0][0]);
-      }
+      RNA_float_set_array(op->ptr, "orient_matrix", &t->spacemtx[0][0]);
     }
   }
 
   if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis"))) {
     bool constraint_axis[3] = {false, false, false};
-    if (t->idx_max == 0) {
-      if (t->con.mode & CON_APPLY) {
-        if (t->con.mode & CON_AXIS0) {
-          constraint_axis[0] = true;
-        }
-        if (t->con.mode & CON_AXIS1) {
-          constraint_axis[1] = true;
-        }
-        if (t->con.mode & CON_AXIS2) {
-          constraint_axis[2] = true;
-        }
-        RNA_property_boolean_set_array(op->ptr, prop, constraint_axis);
+    if (t->con.mode & CON_APPLY) {
+      if (t->con.mode & CON_AXIS0) {
+        constraint_axis[0] = true;
       }
-      else {
-        RNA_property_unset(op->ptr, prop);
+      if (t->con.mode & CON_AXIS1) {
+        constraint_axis[1] = true;
+      }
+      if (t->con.mode & CON_AXIS2) {
+        constraint_axis[2] = true;
       }
+      RNA_property_boolean_set_array(op->ptr, prop, constraint_axis);
     }
     else {
-      constraint_axis[0] = true;
-      constraint_axis[1] = true;
-      constraint_axis[2] = true;
-      RNA_property_boolean_set_array(op->ptr, prop, constraint_axis);
+      RNA_property_unset(op->ptr, prop);
     }
   }
 
@@ -2028,33 +2016,6 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
   calculatePropRatio(t);
   calculateCenter(t);
 
-  /* Overwrite initial values if operator supplied a non-null vector.
-   *
-   * Run before init functions so 'values_modal_offset' can be applied on mouse input.
-   */
-  BLI_assert(is_zero_v4(t->values_modal_offset));
-  if ((prop = RNA_struct_find_property(op->ptr, "value")) && RNA_property_is_set(op->ptr, prop)) {
-    float values[4] = {0}; /* in case value isn't length 4, avoid uninitialized memory  */
-
-    if (RNA_property_array_check(prop)) {
-      RNA_float_get_array(op->ptr, "value", values);
-    }
-    else {
-      values[0] = RNA_float_get(op->ptr, "value");
-    }
-
-    copy_v4_v4(t->values, values);
-
-    if (t->flag & T_MODAL) {
-      copy_v4_v4(t->values_modal_offset, values);
-      t->redraw = TREDRAW_HARD;
-    }
-    else {
-      copy_v4_v4(t->values, values);
-      t->flag |= T_INPUT_IS_VALUES_FINAL;
-    }
-  }
-
   if (event) {
     /* Initialize accurate transform to settings requested by keymap. */
     bool use_accurate = false;
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 9d94d229b25..704a48f3707 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -1595,11 +1595,43 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
     t->around = V3D_AROUND_CENTER_BOUNDS;
   }
 
-  if (op && (prop = RNA_struct_find_property(op->ptr, "constraint_axis")) &&
+  BLI_assert(is_zero_v4(t->values_modal_offset));
+  bool t_values_set_is_array = false;
+  if (op && (prop = RNA_struct_find_property(op->ptr, "value")) &&
       RNA_property_is_set(op->ptr, prop)) {
-    bool constraint_axis[3];
+    float values[4] = {0}; /* in case value isn't length 4, avoid uninitialized memory  */
+    if (RNA_property_array_check(prop)) {
+      RNA_float_get_array(op->ptr, "value", values);
+      t_values_set_is_array = true;
+    }
+    else {
+      values[0] = RNA_float_get(op->ptr, "value");
+    }
+
+    copy_v4_v4(t->values, values);
+    if (t->flag & T_MODAL) {
+      /* Run before init functions so 'values_modal_offset' can be applied on mouse input. */
+      copy_v4_v4(t->values_modal_offset, values);
+    }
+    else {
+      copy_v4_v4(t->values, values);
+      t->flag |= T_INPUT_IS_VALUES_FINAL;
+    }
+  }
 
-    RNA_property_boolean_get_array(op->ptr, prop, constraint_axis);
+  if (op && (prop = RNA_struct_find_property(op->ptr, "constraint_axis"))) {
+    bool constraint_axis[3] = {false, false, false};
+    if (RNA_property_is_set(op->ptr, prop)) {
+      RNA_property_boolean_get_array(op->ptr, prop, constraint_axis);
+    }
+
+    if (t_values_set_is_array && t->flag & T_INPUT_IS_VALUES_FINAL) {
+      /* For operators whose `t->values` is array, set contrain so that the
+       * orientation is more intuitive in the Redo Panel. */
+      for (int i = 3; i--;) {
+        constraint_axis[i] |= t->values[i] != 0.0f;
+      }
+    }
 
     if (constraint_axis[0] || constraint_axis[1] || constraint_axis[2]) {
       t->con.mode |= CON_APPLY;



More information about the Bf-blender-cvs mailing list