diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-04-20 19:06:46 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-04-20 19:06:46 +0400 |
commit | 874c29cea8e6f9bc411fccf2d6f4cb07e94328d0 (patch) | |
tree | 5971e577cf7c02e05a1e37b5ad058c71a6744877 /intern/moto/include | |
parent | 7555bfa793a2b0fc187c6211c56986f35b2d7b09 (diff) | |
parent | c5bc4e4fb1a33eda8c31f2ea02e91f32f74c8fa5 (diff) |
2.50: svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r19323:HEAD
Notes:
* blenderbuttons and ICON_SNAP_PEEL_OBJECT were not merged.
Diffstat (limited to 'intern/moto/include')
-rw-r--r-- | intern/moto/include/MT_Quaternion.inl | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/intern/moto/include/MT_Quaternion.inl b/intern/moto/include/MT_Quaternion.inl index ecfd6699f67..ec747c453d3 100644 --- a/intern/moto/include/MT_Quaternion.inl +++ b/intern/moto/include/MT_Quaternion.inl @@ -74,19 +74,27 @@ GEN_INLINE MT_Scalar MT_Quaternion::angle(const MT_Quaternion& q) const GEN_INLINE MT_Quaternion MT_Quaternion::slerp(const MT_Quaternion& q, const MT_Scalar& t) const { - MT_Scalar theta = angle(q); - - if (!MT_fuzzyZero(theta)) + MT_Scalar d, s0, s1; + MT_Scalar s = dot(q); + bool neg = (s < 0.0); + + if (neg) + s = -s; + if ((1.0 - s) > 0.0001) { - MT_Scalar d = MT_Scalar(1.0) / sin(theta); - MT_Scalar s0 = sin((MT_Scalar(1.0) - t) * theta); - MT_Scalar s1 = sin(t * theta); - - return d*(*this * s0 + q * s1); + MT_Scalar theta = acos(s); + d = MT_Scalar(1.0) / sin(theta); + s0 = sin((MT_Scalar(1.0) - t) * theta); + s1 = sin(t * theta); } else { - return *this; + d = MT_Scalar(1.0); + s0 = MT_Scalar(1.0) - t; + s1 = t; } + if (neg) + s1 = -s1; + return d*(*this * s0 + q * s1); } |