diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-02-05 16:19:14 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-02-05 16:19:14 +0300 |
commit | 90cf78eb5409a77c912b90fb812a4391e31897ae (patch) | |
tree | 23594e3f54008f749cfeacc394134425316d860c /source/blender/editors | |
parent | fe99f35210bfe932e8f1e8161dc9fe68cd09bf5d (diff) |
Fix bones moving when changing between editmode and posemode.
Patch #25901 by Tobias Oelgarte.
Bone transformations would be converted back and forth between different
representations when changing modes, which due to numerical errors could
lead to bone transformations slowly changing as you edit the armature.
Now the editmode head, tail and roll values are stored in bones and used
directly when entering edit mode. Head and tail were already there but
now we ensure they are the exact same value, roll was not yet there, so
we have a version patch for it.
The sub version was incremented to 1 for the version patch.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/armature/editarmature.c | 37 |
1 files changed, 10 insertions, 27 deletions
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 5e54cbf6345..4fc5064cef0 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -246,11 +246,6 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone EditBone *eBoneAct= NULL; EditBone *eBoneTest= NULL; Bone *curBone; - float delta[3]; - float premat[3][3]; - float postmat[3][3]; - float imat[3][3]; - float difmat[3][3]; for (curBone=bones->first; curBone; curBone=curBone->next) { eBone= MEM_callocN(sizeof(EditBone), "make_editbone"); @@ -291,20 +286,8 @@ EditBone *make_boneList(ListBase *edbo, ListBase *bones, EditBone *parent, Bone } copy_v3_v3(eBone->head, curBone->arm_head); - copy_v3_v3(eBone->tail, curBone->arm_tail); - - eBone->roll= 0.0f; - - /* roll fixing */ - sub_v3_v3v3(delta, eBone->tail, eBone->head); - vec_roll_to_mat3(delta, 0.0f, postmat); - - copy_m3_m4(premat, curBone->arm_mat); - - invert_m3_m3(imat, postmat); - mul_m3_m3m3(difmat, imat, premat); - - eBone->roll = (float)atan2(difmat[2][0], difmat[2][2]); + copy_v3_v3(eBone->tail, curBone->arm_tail); + eBone->roll = curBone->arm_roll; /* rest of stuff copy */ eBone->length= curBone->length; @@ -420,8 +403,10 @@ void ED_armature_from_edit(Object *obedit) eBone->temp= newBone; /* Associate the real Bones with the EditBones */ BLI_strncpy(newBone->name, eBone->name, sizeof(newBone->name)); - memcpy(newBone->head, eBone->head, sizeof(newBone->head)); - memcpy(newBone->tail, eBone->tail, sizeof(newBone->tail)); + copy_v3_v3(newBone->arm_head, eBone->head); + copy_v3_v3(newBone->arm_tail, eBone->tail); + newBone->arm_roll = eBone->roll; + newBone->flag= eBone->flag; if (eBone == arm->act_edbone) { @@ -456,7 +441,6 @@ void ED_armature_from_edit(Object *obedit) BLI_addtail(&newBone->parent->childbase, newBone); { - float M_boneRest[3][3]; float M_parentRest[3][3]; float iM_parentRest[3][3]; float delta[3]; @@ -465,10 +449,6 @@ void ED_armature_from_edit(Object *obedit) sub_v3_v3v3(delta, eBone->parent->tail, eBone->parent->head); vec_roll_to_mat3(delta, eBone->parent->roll, M_parentRest); - /* Get this bone's matrix (rotation only) */ - sub_v3_v3v3(delta, eBone->tail, eBone->head); - vec_roll_to_mat3(delta, eBone->roll, M_boneRest); - /* Invert the parent matrix */ invert_m3_m3(iM_parentRest, M_parentRest); @@ -481,8 +461,11 @@ void ED_armature_from_edit(Object *obedit) } } /* ...otherwise add this bone to the armature's bonebase */ - else + else { + copy_v3_v3(newBone->head, eBone->head); + copy_v3_v3(newBone->tail, eBone->tail); BLI_addtail(&arm->bonebase, newBone); + } } /* Make a pass through the new armature to fix rolling */ |