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
path: root/intern
diff options
context:
space:
mode:
authorBenoit Bolsee <benoit.bolsee@online.be>2009-04-17 00:13:13 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2009-04-17 00:13:13 +0400
commit2c491b5d2e6db52e526a39e3040c59db4edd25de (patch)
tree5a6ca10f3dfe7a3cad404512d8c4dd5a23d94d28 /intern
parent32253dfaaf43751037d4dcabd834e812902d6538 (diff)
BGE: slow parent was causing scaling distortion, now use correct quaternion interpolation.
Diffstat (limited to 'intern')
-rw-r--r--intern/moto/include/MT_Quaternion.inl26
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);
}