Extrude Widget: with/without axis constraint
authorCampbell Barton <ideasman42@gmail.com>
Tue, 8 May 2018 18:28:40 +0000 (20:28 +0200)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 8 May 2018 18:30:29 +0000 (20:30 +0200)
source/blender/editors/mesh/editmesh_extrude.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_input.c

index 8c68bb58e7cddd517d0092abbb0b7e29bb14dc60..6c6283633cdb0c76b2c5e2bab5103ec6d6958760 100644 (file)
@@ -500,12 +500,9 @@ static void manipulator_mesh_extrude_refresh(const bContext *C, wmManipulatorGro
                RNA_float_get_array(op_transform->ptr, "value", value);
                RNA_float_set_array(&macroptr, "value", value);
 
-               /* Currently has glitch in re-applying. */
-#if 0
                int constraint_axis[3];
                RNA_boolean_get_array(op_transform->ptr, "constraint_axis", constraint_axis);
                RNA_boolean_set_array(&macroptr, "constraint_axis", constraint_axis);
-#endif
        }
 }
 
index 41cc2087dea22fc5282e95693273cfae01a87b0c..632779d50a4cada3b7ccbbf5e05033af01b8c72d 100644 (file)
@@ -2257,6 +2257,36 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
                }
        }
 
+       /* Transformation axis from operator */
+       if ((prop = RNA_struct_find_property(op->ptr, "axis")) && RNA_property_is_set(op->ptr, prop)) {
+               RNA_property_float_get_array(op->ptr, prop, t->axis);
+               normalize_v3(t->axis);
+               copy_v3_v3(t->axis_orig, t->axis);
+       }
+
+       /* Constraint init from operator */
+       if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis")) && RNA_property_is_set(op->ptr, prop)) {
+               int constraint_axis[3];
+
+               RNA_property_boolean_get_array(op->ptr, prop, constraint_axis);
+
+               if (constraint_axis[0] || constraint_axis[1] || constraint_axis[2]) {
+                       t->con.mode |= CON_APPLY;
+
+                       if (constraint_axis[0]) {
+                               t->con.mode |= CON_AXIS0;
+                       }
+                       if (constraint_axis[1]) {
+                               t->con.mode |= CON_AXIS1;
+                       }
+                       if (constraint_axis[2]) {
+                               t->con.mode |= CON_AXIS2;
+                       }
+
+                       setUserConstraint(t, t->current_orientation, t->con.mode, "%s");
+               }
+       }
+
        if (event) {
                /* Initialize accurate transform to settings requested by keymap. */
                bool use_accurate = false;
@@ -2405,36 +2435,6 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
                return 0;
        }
 
-       /* Transformation axis from operator */
-       if ((prop = RNA_struct_find_property(op->ptr, "axis")) && RNA_property_is_set(op->ptr, prop)) {
-               RNA_property_float_get_array(op->ptr, prop, t->axis);
-               normalize_v3(t->axis);
-               copy_v3_v3(t->axis_orig, t->axis);
-       }
-
-       /* Constraint init from operator */
-       if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis")) && RNA_property_is_set(op->ptr, prop)) {
-               int constraint_axis[3];
-
-               RNA_property_boolean_get_array(op->ptr, prop, constraint_axis);
-
-               if (constraint_axis[0] || constraint_axis[1] || constraint_axis[2]) {
-                       t->con.mode |= CON_APPLY;
-
-                       if (constraint_axis[0]) {
-                               t->con.mode |= CON_AXIS0;
-                       }
-                       if (constraint_axis[1]) {
-                               t->con.mode |= CON_AXIS1;
-                       }
-                       if (constraint_axis[2]) {
-                               t->con.mode |= CON_AXIS2;
-                       }
-
-                       setUserConstraint(t, t->current_orientation, t->con.mode, "%s");
-               }
-       }
-
        t->context = NULL;
 
        return 1;
index 799d2acb91894b8d917fb09fe84e72c2c5d9bd66..3e4efaa939b20a63e369c325df70fc7a6832f12a 100644 (file)
@@ -419,7 +419,12 @@ void applyMouseInput(TransInfo *t, MouseInput *mi, const int mval[2], float outp
 
        if (!is_zero_v3(t->values_modal_offset)) {
                float values_ofs[3];
-               mul_v3_m3v3(values_ofs, t->spacemtx, t->values_modal_offset);
+               if (t->con.mode & CON_APPLY) {
+                       mul_v3_m3v3(values_ofs, t->spacemtx, t->values_modal_offset);
+               }
+               else {
+                       copy_v3_v3(values_ofs, t->values_modal_offset);
+               }
                add_v3_v3(t->values, values_ofs);
        }