[Bf-blender-cvs] [80ef7fbeb15] master: Transform: refactor orientation naming and usasge

Campbell Barton noreply at git.blender.org
Wed Feb 27 07:32:27 CET 2019


Commit: 80ef7fbeb15f388097e2f778d41f7280e77779cf
Author: Campbell Barton
Date:   Wed Feb 27 17:25:45 2019 +1100
Branches: master
https://developer.blender.org/rB80ef7fbeb15f388097e2f778d41f7280e77779cf

Transform: refactor orientation naming and usasge

Transform orientation was previously related to constraints,
recent changes meant it was used even when not constraining to an axis.

Now transform orientation is separate from axis constraints.

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

M	release/scripts/startup/bl_operators/view3d.py
M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/editors/include/ED_transform.h
M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform_generics.c
M	source/blender/editors/transform/transform_gizmo_3d.c
M	source/blender/editors/transform/transform_gizmo_extrude_3d.c
M	source/blender/editors/transform/transform_ops.c

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

diff --git a/release/scripts/startup/bl_operators/view3d.py b/release/scripts/startup/bl_operators/view3d.py
index 5ae112e57e4..2dd4b7457ed 100644
--- a/release/scripts/startup/bl_operators/view3d.py
+++ b/release/scripts/startup/bl_operators/view3d.py
@@ -45,7 +45,7 @@ class VIEW3D_OT_edit_mesh_extrude_individual_move(Operator):
             bpy.ops.mesh.extrude_region_move(
                 'INVOKE_REGION_WIN',
                 TRANSFORM_OT_translate={
-                    "constraint_orientation": 'NORMAL',
+                    "orient_type": 'NORMAL',
                     "constraint_axis": (False, False, True),
                 }
             )
@@ -92,7 +92,7 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
                 bpy.ops.mesh.extrude_region_move(
                     'INVOKE_REGION_WIN',
                     TRANSFORM_OT_translate={
-                        "constraint_orientation": 'NORMAL',
+                        "orient_type": 'NORMAL',
                         "constraint_axis": (False, False, True),
                     },
                 )
@@ -103,7 +103,7 @@ class VIEW3D_OT_edit_mesh_extrude_move(Operator):
                 TRANSFORM_OT_translate={
                     # Don't set the constraint axis since users will expect MMB
                     # to use the user setting, see: T61637
-                    # "constraint_orientation": 'NORMAL',
+                    # "orient_type": 'NORMAL',
                     # Not a popular choice, too restrictive for retopo.
                     # "constraint_axis": (True, True, False)})
                     "constraint_axis": (False, False, False),
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 7a17cb864c6..d44f0943c30 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -507,26 +507,26 @@ class VIEW3D_MT_mirror(Menu):
 
         props = layout.operator("transform.mirror", text="X Global")
         props.constraint_axis = (True, False, False)
-        props.constraint_orientation = 'GLOBAL'
+        props.orient_type = 'GLOBAL'
         props = layout.operator("transform.mirror", text="Y Global")
         props.constraint_axis = (False, True, False)
-        props.constraint_orientation = 'GLOBAL'
+        props.orient_type = 'GLOBAL'
         props = layout.operator("transform.mirror", text="Z Global")
         props.constraint_axis = (False, False, True)
-        props.constraint_orientation = 'GLOBAL'
+        props.orient_type = 'GLOBAL'
 
         if context.edit_object:
             layout.separator()
 
             props = layout.operator("transform.mirror", text="X Local")
             props.constraint_axis = (True, False, False)
-            props.constraint_orientation = 'LOCAL'
+            props.orient_type = 'LOCAL'
             props = layout.operator("transform.mirror", text="Y Local")
             props.constraint_axis = (False, True, False)
-            props.constraint_orientation = 'LOCAL'
+            props.orient_type = 'LOCAL'
             props = layout.operator("transform.mirror", text="Z Local")
             props.constraint_axis = (False, False, True)
-            props.constraint_orientation = 'LOCAL'
+            props.orient_type = 'LOCAL'
 
             layout.operator("object.vertex_group_mirror")
 
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index 88e821091f5..1bd8782bb12 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -136,6 +136,7 @@ int BIF_countTransformOrientation(const struct bContext *C);
 #define P_PROPORTIONAL  (1 << 1)
 #define P_ORIENT_AXIS (1 << 2)
 #define P_ORIENT_AXIS_ORTHO (1 << 16)
+#define P_ORIENT_MATRIX (1 << 17)
 #define P_SNAP          (1 << 3)
 #define P_GEO_SNAP      (P_SNAP | (1 << 4))
 #define P_ALIGN_SNAP    (P_GEO_SNAP | (1 << 5))
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 34a6c64b90f..53c5fbddcdb 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -2055,7 +2055,6 @@ static void drawTransformPixel(const struct bContext *C, ARegion *ar, void *arg)
 void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
 {
 	ToolSettings *ts = CTX_data_tool_settings(C);
-	bool constraint_axis[3] = {false, false, false};
 	int proportional = 0;
 	PropertyRNA *prop;
 
@@ -2137,7 +2136,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
 		}
 
 		if (t->spacetype == SPACE_VIEW3D) {
-			if ((prop = RNA_struct_find_property(op->ptr, "constraint_orientation")) &&
+			if ((prop = RNA_struct_find_property(op->ptr, "orient_type")) &&
 			    !RNA_property_is_set(op->ptr, prop) &&
 			    (t->orientation.user != V3D_ORIENT_CUSTOM_MATRIX))
 			{
@@ -2156,6 +2155,20 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
 		RNA_float_set(op->ptr, "proportional_size", t->prop_size);
 	}
 
+	if ((prop = RNA_struct_find_property(op->ptr, "mirror"))) {
+		RNA_property_boolean_set(op->ptr, prop, (t->flag & T_NO_MIRROR) == 0);
+	}
+
+	short orientation = (t->con.mode & CON_APPLY) ? t->con.orientation : t->orientation.unset;
+	if (orientation == V3D_ORIENT_CUSTOM) {
+		const int orientation_index_custom = BKE_scene_transform_orientation_get_index(
+		        t->scene, t->orientation.custom);
+		/* Maybe we need a t->con.custom_orientation?
+		 * Seems like it would always match t->orientation.custom. */
+		orientation = V3D_ORIENT_CUSTOM + orientation_index_custom;
+		BLI_assert(orientation >= V3D_ORIENT_CUSTOM);
+	}
+
 	if ((prop = RNA_struct_find_property(op->ptr, "orient_axis"))) {
 		if (t->flag & T_MODAL) {
 			if (t->con.mode & CON_APPLY) {
@@ -2167,45 +2180,41 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
 		}
 	}
 
-	if ((prop = RNA_struct_find_property(op->ptr, "mirror"))) {
-		RNA_property_boolean_set(op->ptr, prop, (t->flag & T_NO_MIRROR) == 0);
-	}
-
-	if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis"))) {
-		/* constraint orientation can be global, even if user selects something else
-		 * so use the orientation in the constraint if set */
-		short orientation = (t->con.mode & CON_APPLY) ? t->con.orientation : t->orientation.unset;
-
-		if (orientation == V3D_ORIENT_CUSTOM) {
-			const int orientation_index_custom = BKE_scene_transform_orientation_get_index(
-			        t->scene, t->orientation.custom);
-
-			/* Maybe we need a t->con.custom_orientation?
-			 * Seems like it would always match t->orientation.custom. */
-			orientation = V3D_ORIENT_CUSTOM + orientation_index_custom;
-			BLI_assert(orientation >= V3D_ORIENT_CUSTOM);
-		}
-
-		/* Use 'constraint_matrix' instead. */
-		if (orientation != V3D_ORIENT_CUSTOM_MATRIX) {
-			RNA_enum_set(op->ptr, "constraint_orientation", orientation);
-		}
-
+	if ((prop = RNA_struct_find_property(op->ptr, "orient_matrix"))) {
 		if (t->flag & T_MODAL) {
 			if (orientation != V3D_ORIENT_CUSTOM_MATRIX) {
 				if (t->flag & T_MODAL) {
-					RNA_enum_set(op->ptr, "constraint_matrix_orientation", orientation);
+					RNA_enum_set(op->ptr, "orient_matrix_type", orientation);
 				}
 			}
 			if (t->con.mode & CON_APPLY) {
-				RNA_float_set_array(op->ptr, "constraint_matrix", &t->con.mtx[0][0]);
+				RNA_float_set_array(op->ptr, "orient_matrix", &t->con.mtx[0][0]);
 			}
 			else if (t->orient_matrix_is_set) {
-				RNA_float_set_array(op->ptr, "constraint_matrix", &t->orient_matrix[0][0]);
+				RNA_float_set_array(op->ptr, "orient_matrix", &t->orient_matrix[0][0]);
 			}
 			else {
-				RNA_float_set_array(op->ptr, "constraint_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, "orient_type"))) {
+		/* constraint orientation can be global, even if user selects something else
+		 * so use the orientation in the constraint if set */
+
+		/* Use 'orient_matrix' instead. */
+		if (orientation != V3D_ORIENT_CUSTOM_MATRIX) {
+			RNA_property_enum_set(op->ptr, prop, orientation);
+		}
+	}
+
+	if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis"))) {
+		bool constraint_axis[3] = {false, false, false};
+		if (t->flag & T_MODAL) {
+			/* Only set if needed, so we can hide in the UI when nothing is set.
+			 * See 'transform_poll_property'. */
 			if (t->con.mode & CON_APPLY) {
 				if (t->con.mode & CON_AXIS0) {
 					constraint_axis[0] = true;
@@ -2217,9 +2226,6 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
 					constraint_axis[2] = true;
 				}
 			}
-
-			/* Only set if needed, so we can hide in the UI when nothing is set.
-			 * See 'transform_poll_property'. */
 			if (ELEM(true, UNPACK3(constraint_axis))) {
 				RNA_property_boolean_set_array(op->ptr, prop, constraint_axis);
 			}
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 98031fd0ed4..fb52918de9b 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -1518,13 +1518,13 @@ 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_matrix")) &&
+	if (op && ((prop = RNA_struct_find_property(op->ptr, "orient_matrix")) &&
 	           RNA_property_is_set(op->ptr, prop)) &&
 	    ((t->flag & T_MODAL) ||
 	     /* When using redo, don't use the the custom constraint matrix
 	      * if the user selects a different orientation. */
-	     (RNA_enum_get(op->ptr, "constraint_orientation") ==
-	      RNA_enum_get(op->ptr, "constraint_matrix_orientation"))))
+	     (RNA_enum_get(op->ptr, "orient_type") ==
+	      RNA_enum_get(op->ptr, "orient_matrix_type"))))
 	{
 		RNA_property_float_get_array(op->ptr, prop, &t->spacemtx[0][0]);
 		/* Some transform modes use this to operate on an axis. */
@@ -1534,10 +1534,10 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
 		

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list