[Bf-blender-cvs] [899947c] master: Fix T48679: Bone transform only alters between translation and rotation

Sergey Sharybin noreply at git.blender.org
Fri Jul 29 14:47:40 CEST 2016


Commit: 899947c89eaec5c87d079e2f4835501c9b8df014
Author: Sergey Sharybin
Date:   Fri Jul 29 14:45:27 2016 +0200
Branches: master
https://developer.blender.org/rB899947c89eaec5c87d079e2f4835501c9b8df014

Fix T48679: Bone transform only alters between translation and rotation

There was some smart code in the transform which would alter between translation
and rotation based on whether bone is connected or not and whether translation is
locked or not.

It could be handy to also fallback to scale if both rotation and translation are
locked.

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

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

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

diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index b7456fa..1376b6b 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -701,7 +701,6 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob)
 	bPoseChannel *pchan;
 	Bone *bone;
 	int mode = *out_mode;
-	int hastranslation = 0;
 	int total = 0;
 
 	for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
@@ -729,7 +728,7 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob)
 		}
 	}
 	/* now count, and check if we have autoIK or have to switch from translate to rotate */
-	hastranslation = 0;
+	bool has_translation = false, has_rotation = false;
 
 	for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
 		bone = pchan->bone;
@@ -740,20 +739,29 @@ int count_set_pose_transflags(int *out_mode, short around, Object *ob)
 				if (has_targetless_ik(pchan) == NULL) {
 					if (pchan->parent && (pchan->bone->flag & BONE_CONNECTED)) {
 						if (pchan->bone->flag & BONE_HINGE_CHILD_TRANSFORM)
-							hastranslation = 1;
+							has_translation = true;
 					}
-					else if ((pchan->protectflag & OB_LOCK_LOC) != OB_LOCK_LOC)
-						hastranslation = 1;
+					else {
+						if ((pchan->protectflag & OB_LOCK_LOC) != OB_LOCK_LOC)
+							has_translation = true;
+					}
+					if ((pchan->protectflag & OB_LOCK_ROT) != OB_LOCK_ROT)
+						has_rotation = true;
 				}
 				else
-					hastranslation = 1;
+					has_translation = true;
 			}
 		}
 	}
 
 	/* if there are no translatable bones, do rotation */
-	if (mode == TFM_TRANSLATION && !hastranslation) {
-		*out_mode = TFM_ROTATION;
+	if (mode == TFM_TRANSLATION && !has_translation) {
+		if (has_rotation) {
+			*out_mode = TFM_ROTATION;
+		}
+		else {
+			*out_mode = TFM_RESIZE;
+		}
 	}
 
 	return total;




More information about the Bf-blender-cvs mailing list