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.
This commit is contained in:
2014-10-22 11:11:52 +02:00
parent 33f388d7bf
commit 769c0bee9f
2 changed files with 27 additions and 9 deletions

View File

@@ -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++;
}
}

View File

@@ -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;
}
}