diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-10-12 04:08:34 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-10-12 04:08:34 +0400 |
commit | 744f691af42ffeadd306180048c51edad65a5f06 (patch) | |
tree | 5611ce8cf10dde0b620d79a4d59736134dff1881 /source | |
parent | 312795225995e93ac47c462c0a4c062c9719592a (diff) |
Fix dual quaternion armature deform giving erratic results in some cases. Bug
was encountered in a Kiribati rig file.
The problem was actually in the matrix to quaternion conversion function. One
problem is that it was using the wrong matrix indices in case of an ill defined
matrix trace. Besides that FLT_EPSILON was too small to detect cases where
float precision becomes a problem.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/intern/math_rotation.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 6bac102e1b1..a056f014b1c 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -286,7 +286,7 @@ void mat3_to_quat(float q[4], float wmat[3][3]) tr = 0.25 * (double)(1.0f + mat[0][0] + mat[1][1] + mat[2][2]); - if (tr > (double)FLT_EPSILON) { + if (tr > (double)1e-6f) { s = sqrt(tr); q[0] = (float)s; s = 1.0 / (4.0 * s); @@ -300,7 +300,7 @@ void mat3_to_quat(float q[4], float wmat[3][3]) q[1] = (float)(0.25 * s); s = 1.0 / s; - q[0] = (float)((double)(mat[2][1] - mat[1][2]) * s); + q[0] = (float)((double)(mat[1][2] - mat[2][1]) * s); q[2] = (float)((double)(mat[1][0] + mat[0][1]) * s); q[3] = (float)((double)(mat[2][0] + mat[0][2]) * s); } @@ -318,7 +318,7 @@ void mat3_to_quat(float q[4], float wmat[3][3]) q[3] = (float)(0.25 * s); s = 1.0 / s; - q[0] = (float)((double)(mat[1][0] - mat[0][1]) * s); + q[0] = (float)((double)(mat[0][1] - mat[1][0]) * s); q[1] = (float)((double)(mat[2][0] + mat[0][2]) * s); q[2] = (float)((double)(mat[2][1] + mat[1][2]) * s); } |