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>2019-11-29 06:57:07 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-11-29 10:09:47 +0300
commitac15f5e9b09182340a008cb8c7605777d6736b2b (patch)
tree97ec51b53451555e58aaace2e6043f226d0cab74
parent77c7440540626828b080444165a28887c255594e (diff)
Cleanup: comments, redundant normalize
-rw-r--r--source/blender/blenkernel/intern/armature.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 7d10bce60ef..a694a335069 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -281,6 +281,11 @@ static void armature_transform_recurse(ListBase *bonebase,
{
for (Bone *bone = bonebase->first; bone; bone = bone->next) {
+ /* Store the initial bone roll in a matrix, this is needed even for child bones
+ * so any change in head/tail doesn't cause the roll to change.
+ *
+ * Logic here is different to edit-mode because
+ * this is calculated in relative to the parent. */
float roll_mat3_pre[3][3];
{
float delta[3];
@@ -290,6 +295,7 @@ static void armature_transform_recurse(ListBase *bonebase,
mul_m3_m3m3(roll_mat3_pre, mat3, roll_mat3_pre);
}
}
+ /* Optional, use this for predictable results since the roll is re-calculated below anyway. */
bone->roll = 0.0f;
mul_m4_v3(mat, bone->arm_head);
@@ -308,17 +314,14 @@ static void armature_transform_recurse(ListBase *bonebase,
copy_v3_v3(bone->tail, bone->arm_tail);
}
+ /* Now the head/tail have been updated, set the roll back, matching 'roll_mat3_pre'. */
{
- float roll_mat3_post[3][3];
- float delta_mat3[3][3];
+ float roll_mat3_post[3][3], delta_mat3[3][3];
float delta[3];
sub_v3_v3v3(delta, bone->tail, bone->head);
- vec_roll_to_mat3(delta, bone->roll, roll_mat3_post);
- normalize_v3(delta);
-
+ vec_roll_to_mat3(delta, 0.0f, roll_mat3_post);
invert_m3(roll_mat3_post);
mul_m3_m3m3(delta_mat3, roll_mat3_post, roll_mat3_pre);
-
bone->roll = atan2f(delta_mat3[2][0], delta_mat3[2][2]);
}