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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2010-02-22 21:53:46 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2010-02-22 21:53:46 +0300
commitb7e7a0140b8d4a7a9b4598a3fb30ed844c394e5a (patch)
tree8d26ee8f944b72cc84a3b309c2c7bdd57b58540b /source/blender/blenlib/intern/math_rotation.c
parent2b9740bc3b6f1a808e49882911fdd434e090318d (diff)
Fix dual quaternions flipping in case of stretched (not scaled) bones.
Diffstat (limited to 'source/blender/blenlib/intern/math_rotation.c')
-rw-r--r--source/blender/blenlib/intern/math_rotation.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index 8d5684a3ac8..a92f80e35c7 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -1333,8 +1333,14 @@ void mat4_to_dquat(DualQuat *dq,float basemat[][4], float mat[][4])
if((determinant_m4(mat) < 0.0f) || len_v3(dscale) > 1e-4) {
/* extract R and S */
- mat4_to_quat(basequat,baseRS);
- quat_to_mat4(baseR,basequat);
+ float tmp[4][4];
+
+ /* extra orthogonalize, to avoid flipping with stretched bones */
+ copy_m4_m4(tmp, baseRS);
+ orthogonalize_m4(tmp, 1);
+ mat4_to_quat(basequat, tmp);
+
+ quat_to_mat4(baseR, basequat);
copy_v3_v3(baseR[3], baseRS[3]);
invert_m4_m4(baseinv, basemat);