diff options
Diffstat (limited to 'source/blender/editors/armature')
-rw-r--r-- | source/blender/editors/armature/armature_edit.c | 10 | ||||
-rw-r--r-- | source/blender/editors/armature/armature_relations.c | 9 | ||||
-rw-r--r-- | source/blender/editors/armature/armature_utils.c | 27 |
3 files changed, 28 insertions, 18 deletions
diff --git a/source/blender/editors/armature/armature_edit.c b/source/blender/editors/armature/armature_edit.c index 12602c10955..90c1a439a19 100644 --- a/source/blender/editors/armature/armature_edit.c +++ b/source/blender/editors/armature/armature_edit.c @@ -78,11 +78,10 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4]) /* Do the rotations */ for (ebone = arm->edbo->first; ebone; ebone = ebone->next) { - float delta[3], tmat[3][3]; + float tmat[3][3]; /* find the current bone's roll matrix */ - sub_v3_v3v3(delta, ebone->tail, ebone->head); - vec_roll_to_mat3(delta, ebone->roll, tmat); + ED_armature_ebone_to_mat3(ebone, tmat); /* transform the roll matrix */ mul_m3_m3m3(tmat, mat3, tmat); @@ -282,15 +281,14 @@ static int armature_calc_roll_exec(bContext *C, wmOperator *op) mul_m3_v3(imat, vec); } else if (type == CALC_ROLL_ACTIVE) { - float mat[3][3], nor[3]; + float mat[3][3]; ebone = (EditBone *)arm->act_edbone; if (ebone == NULL) { BKE_report(op->reports, RPT_ERROR, "No active bone set"); return OPERATOR_CANCELLED; } - sub_v3_v3v3(nor, ebone->tail, ebone->head); - vec_roll_to_mat3(nor, ebone->roll, mat); + ED_armature_ebone_to_mat3(ebone, mat); copy_v3_v3(vec, mat[2]); } else { /* Axis */ diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c index 289901076a1..79d75c9fcda 100644 --- a/source/blender/editors/armature/armature_relations.c +++ b/source/blender/editors/armature/armature_relations.c @@ -242,21 +242,18 @@ int join_armature_exec(bContext *C, wmOperator *op) float difmat[4][4]; float imat[4][4]; float temp[3][3]; - float delta[3]; /* Get the premat */ - sub_v3_v3v3(delta, curbone->tail, curbone->head); - vec_roll_to_mat3(delta, curbone->roll, temp); + ED_armature_ebone_to_mat3(curbone, temp); - unit_m4(premat); /* Mat4MulMat34 only sets 3x3 part */ + unit_m4(premat); /* mul_m4_m3m4 only sets 3x3 part */ mul_m4_m3m4(premat, temp, mat); mul_m4_v3(mat, curbone->head); mul_m4_v3(mat, curbone->tail); /* Get the postmat */ - sub_v3_v3v3(delta, curbone->tail, curbone->head); - vec_roll_to_mat3(delta, curbone->roll, temp); + ED_armature_ebone_to_mat3(curbone, temp); copy_m4_m3(postmat, temp); /* Find the roll */ diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index 0e93a00b01d..4991ef63cf5 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -156,6 +156,25 @@ bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebon return false; } +void ED_armature_ebone_to_mat3(EditBone *ebone, float mat[3][3]) +{ + float delta[3]; + + /* Find the current bone matrix */ + sub_v3_v3v3(delta, ebone->tail, ebone->head); + vec_roll_to_mat3(delta, ebone->roll, mat); +} + +void ED_armature_ebone_to_mat4(EditBone *ebone, float mat[4][4]) +{ + float m3[3][3]; + + ED_armature_ebone_to_mat3(ebone, m3); + + copy_m4_m3(mat, m3); + copy_v3_v3(mat[3], ebone->head); +} + /* *************************************************************** */ /* Mirroring */ @@ -389,7 +408,6 @@ static void fix_bonelist_roll(ListBase *bonelist, ListBase *editbonelist) float postmat[3][3]; float difmat[3][3]; float imat[3][3]; - float delta[3]; for (curBone = bonelist->first; curBone; curBone = curBone->next) { /* sets local matrix and arm_mat (restpos) */ @@ -402,8 +420,7 @@ static void fix_bonelist_roll(ListBase *bonelist, ListBase *editbonelist) if (ebone) { /* Get the ebone premat */ - sub_v3_v3v3(delta, ebone->tail, ebone->head); - vec_roll_to_mat3(delta, ebone->roll, premat); + ED_armature_ebone_to_mat3(ebone, premat); /* Get the bone postmat */ copy_m3_m4(postmat, curBone->arm_mat); @@ -503,11 +520,9 @@ void ED_armature_from_edit(Object *obedit) { float M_parentRest[3][3]; float iM_parentRest[3][3]; - float delta[3]; /* Get the parent's matrix (rotation only) */ - sub_v3_v3v3(delta, eBone->parent->tail, eBone->parent->head); - vec_roll_to_mat3(delta, eBone->parent->roll, M_parentRest); + ED_armature_ebone_to_mat3(eBone->parent, M_parentRest); /* Invert the parent matrix */ invert_m3_m3(iM_parentRest, M_parentRest); |