[Bf-blender-cvs] [769c0bee] master: Fix T42334: x-mirror fails in armature with a partially mirrored chain.

Lukas Tönne noreply at git.blender.org
Wed Oct 22 11:13:29 CEST 2014


Commit: 769c0bee9fafec1ffce05af4e0d1f443dfb95ed7
Author: Lukas Tönne
Date:   Wed Oct 22 11:11:52 2014 +0200
Branches: master
https://developer.blender.org/rB769c0bee9fafec1ffce05af4e0d1f443dfb95ed7

Fix T42334: x-mirror fails in armature with a partially mirrored chain.

When resetting edit bones on cancel, they also have to reset connected
parent and child bone tips and heads respectively, since these can be
modified during the transform.

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

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

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

diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 3b92e01..6d6a1ea 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -1056,11 +1056,13 @@ static void createTransPose(TransInfo *t, Object *ob)
 
 void restoreBones(TransInfo *t)
 {
+	bArmature *arm = t->obedit->data;
 	BoneInitData *bid = t->customData;
-	EditBone *ebo;
+	EditBone *ebo, *children;
 
 	while (bid->bone) {
 		ebo = bid->bone;
+		
 		ebo->dist = bid->dist;
 		ebo->rad_tail = bid->rad_tail;
 		ebo->roll = bid->roll;
@@ -1068,7 +1070,22 @@ void restoreBones(TransInfo *t)
 		ebo->zwidth = bid->zwidth;
 		copy_v3_v3(ebo->head, bid->head);
 		copy_v3_v3(ebo->tail, bid->tail);
-
+		
+		/* Also move connected children, in case children's name aren't mirrored properly */
+		for (children = arm->edbo->first; children; children = children->next) {
+			if (children->parent == ebo && children->flag & BONE_CONNECTED) {
+				copy_v3_v3(children->head, ebo->tail);
+				children->rad_head = ebo->rad_tail;
+			}
+		}
+		
+		/* Also move connected parent, in case parent's name isn't mirrored properly */
+		if (ebo->parent && ebo->flag & BONE_CONNECTED) {
+			EditBone *parent = ebo->parent;
+			copy_v3_v3(parent->tail, ebo->head);
+			parent->rad_tail = ebo->rad_head;
+		}
+		
 		bid++;
 	}
 }
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index b02671e..2f03594 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -779,7 +779,7 @@ static void recalcData_objects(TransInfo *t)
 		else if (t->obedit->type == OB_ARMATURE) { /* no recalc flag, does pose */
 			bArmature *arm = t->obedit->data;
 			ListBase *edbo = arm->edbo;
-			EditBone *ebo;
+			EditBone *ebo, *ebo_parent;
 			TransData *td = t->data;
 			int i;
 			
@@ -789,17 +789,18 @@ static void recalcData_objects(TransInfo *t)
 			
 			/* Ensure all bones are correctly adjusted */
 			for (ebo = edbo->first; ebo; ebo = ebo->next) {
+				ebo_parent = (ebo->flag & BONE_CONNECTED) ? ebo->parent : NULL;
 				
-				if ((ebo->flag & BONE_CONNECTED) && ebo->parent) {
+				if (ebo_parent) {
 					/* If this bone has a parent tip that has been moved */
-					if (ebo->parent->flag & BONE_TIPSEL) {
-						copy_v3_v3(ebo->head, ebo->parent->tail);
-						if (t->mode == TFM_BONE_ENVELOPE) ebo->rad_head = ebo->parent->rad_tail;
+					if (ebo_parent->flag & BONE_TIPSEL) {
+						copy_v3_v3(ebo->head, ebo_parent->tail);
+						if (t->mode == TFM_BONE_ENVELOPE) ebo->rad_head = ebo_parent->rad_tail;
 					}
 					/* If this bone has a parent tip that has NOT been moved */
 					else {
-						copy_v3_v3(ebo->parent->tail, ebo->head);
-						if (t->mode == TFM_BONE_ENVELOPE) ebo->parent->rad_tail = ebo->rad_head;
+						copy_v3_v3(ebo_parent->tail, ebo->head);
+						if (t->mode == TFM_BONE_ENVELOPE) ebo_parent->rad_tail = ebo->rad_head;
 					}
 				}




More information about the Bf-blender-cvs mailing list