[Bf-blender-cvs] [0a87bf67849] master: Transform: don't set the user constraint when it's not set

Campbell Barton noreply at git.blender.org
Tue Feb 26 11:18:09 CET 2019


Commit: 0a87bf67849be91d4b874862815c8ca9e93a4047
Author: Campbell Barton
Date:   Tue Feb 26 20:17:40 2019 +1100
Branches: master
https://developer.blender.org/rB0a87bf67849be91d4b874862815c8ca9e93a4047

Transform: don't set the user constraint when it's not set

The orientation for the redo panel would be set even when not used,
add an 'unset' orientation which defaults to global.

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

M	source/blender/editors/transform/transform.c
M	source/blender/editors/transform/transform.h
M	source/blender/editors/transform/transform_constraints.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 487adf29ad8..e10d32716ac 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -2171,7 +2171,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
 	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.user;
+		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(
@@ -2194,7 +2194,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
 					RNA_enum_set(op->ptr, "constraint_matrix_orientation", orientation);
 				}
 			}
-			if (t->con.mode & CON_APPLY) {
+			if (t->con.mode & CON_APPLY || (t->orientation.unset != V3D_ORIENT_GLOBAL)) {
 				RNA_float_set_array(op->ptr, "constraint_matrix", &t->con.mtx[0][0]);
 			}
 			else {
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 881de792391..b234dabdc0b 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -607,6 +607,10 @@ typedef struct TransInfo {
 	short		launch_event;
 
 	struct {
+		/** Orientation type when when we're not constrained.
+		 * nearly always global except for rotate which defaults to screen-space orientation. */
+		short		unset;
+		/** Orientation to use when a key is pressed. */
 		short		user;
 		/* Used when user is global. */
 		short		user_alt;
@@ -913,7 +917,8 @@ void constraintNumInput(TransInfo *t, float vec[3]);
 
 bool isLockConstraint(TransInfo *t);
 int  getConstraintSpaceDimension(TransInfo *t);
-char constraintModeToChar(TransInfo *t);
+int  constraintModeToIndex(const TransInfo *t);
+char constraintModeToChar(const TransInfo *t);
 
 void startConstraint(TransInfo *t);
 void stopConstraint(TransInfo *t);
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 5bf65c16329..4bed5a3f05c 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -1092,26 +1092,35 @@ void setNearestAxis(TransInfo *t)
 
 /*-------------- HELPER FUNCTIONS ----------------*/
 
-char constraintModeToChar(TransInfo *t)
+int constraintModeToIndex(const TransInfo *t)
 {
 	if ((t->con.mode & CON_APPLY) == 0) {
-		return '\0';
+		return -1;
 	}
 	switch (t->con.mode & (CON_AXIS0 | CON_AXIS1 | CON_AXIS2)) {
 		case (CON_AXIS0):
 		case (CON_AXIS1 | CON_AXIS2):
-			return 'X';
+			return 0;
 		case (CON_AXIS1):
 		case (CON_AXIS0 | CON_AXIS2):
-			return 'Y';
+			return 1;
 		case (CON_AXIS2):
 		case (CON_AXIS0 | CON_AXIS1):
-			return 'Z';
+			return 2;
 		default:
-			return '\0';
+			return -1;
 	}
 }
 
+char constraintModeToChar(const TransInfo *t)
+{
+	int index = constraintModeToIndex(t);
+	if (index == -1) {
+		return '\0';
+	}
+	BLI_assert((uint)index < 3);
+	return 'X' + index;
+}
 
 bool isLockConstraint(TransInfo *t)
 {
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 0bdd18793f4..9dc64d9fd49 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -1410,6 +1410,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
 		}
 
 		TransformOrientationSlot *orient_slot = &t->scene->orientation_slots[SCE_ORIENT_DEFAULT];
+		t->orientation.unset = V3D_ORIENT_GLOBAL;
 		t->orientation.user = orient_slot->type;
 		t->orientation.custom = BKE_scene_transform_orientation_find(t->scene, orient_slot->index_custom);



More information about the Bf-blender-cvs mailing list