Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-08-26 10:22:12 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-08-26 10:22:12 +0400
commite5ddaefecc1c6df3df15f22d6ce5609bb5c6cc3d (patch)
treeaf3b73c007d671ab54053d9830d59d7ca00f31ba /source/blender/editors
parente9ca846018cf861dede652cf2edbefac95b11d4d (diff)
when applying armature object transform now transform the bone roll too.
This means you can import a BVH, rotate 90d and apply the rotation, the animation will still work as expected - thanks to Benjy's script for showing how obvious it is that this works :)
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/armature/editarmature.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index bd8f431535e..451154ce842 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -494,15 +494,32 @@ void ED_armature_apply_transform(Object *ob, float mat[4][4])
EditBone *ebone;
bArmature *arm= ob->data;
float scale = mat4_to_scale(mat); /* store the scale of the matrix here to use on envelopes */
-
+ float mat3[3][3];
+
+ copy_m3_m4(mat3, mat);
+ normalize_m3(mat3);
+
/* Put the armature into editmode */
ED_armature_to_edit(ob);
/* Do the rotations */
- for (ebone = arm->edbo->first; ebone; ebone=ebone->next){
+ for (ebone = arm->edbo->first; ebone; ebone=ebone->next) {
+ float delta[3], 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);
+
+ /* transform the roll matrix */
+ mul_m3_m3m3(tmat, mat3, tmat);
+
+ /* transform the bone */
mul_m4_v3(mat, ebone->head);
mul_m4_v3(mat, ebone->tail);
-
+
+ /* apply the transfiormed roll back */
+ mat3_to_vec_roll(tmat, delta, &ebone->roll);
+
ebone->rad_head *= scale;
ebone->rad_tail *= scale;
ebone->dist *= scale;