improvements in slerp

thanks to Tully Foote:

http://code.google.com/p/bullet/issues/detail?id=140

minor warning fix in btHashMap.h
This commit is contained in:
erwin.coumans
2009-11-03 06:22:51 +00:00
parent 836234696d
commit 992c5eafa4
2 changed files with 12 additions and 5 deletions

View File

@@ -47,7 +47,7 @@ struct btHashString
return( ret ); return( ret );
} }
const bool equals(const btHashString& other) const bool equals(const btHashString& other) const
{ {
return (m_string == other.m_string) || return (m_string == other.m_string) ||
(0==portableStringCompare(m_string,other.m_string)); (0==portableStringCompare(m_string,other.m_string));

View File

@@ -285,10 +285,17 @@ public:
btScalar d = btScalar(1.0) / btSin(theta); btScalar d = btScalar(1.0) / btSin(theta);
btScalar s0 = btSin((btScalar(1.0) - t) * theta); btScalar s0 = btSin((btScalar(1.0) - t) * theta);
btScalar s1 = btSin(t * theta); btScalar s1 = btSin(t * theta);
return btQuaternion((m_floats[0] * s0 + q.x() * s1) * d, if (dot(q) < 0) // Take care of long angle case see http://en.wikipedia.org/wiki/Slerp
(m_floats[1] * s0 + q.y() * s1) * d, return btQuaternion((m_floats[0] * s0 + -q.x() * s1) * d,
(m_floats[2] * s0 + q.z() * s1) * d, (m_floats[1] * s0 + -q.y() * s1) * d,
(m_floats[3] * s0 + q.m_floats[3] * s1) * d); (m_floats[2] * s0 + -q.z() * s1) * d,
(m_floats[3] * s0 + -q.m_floats[3] * s1) * d);
else
return btQuaternion((m_floats[0] * s0 + q.x() * s1) * d,
(m_floats[1] * s0 + q.y() * s1) * d,
(m_floats[2] * s0 + q.z() * s1) * d,
(m_floats[3] * s0 + q.m_floats[3] * s1) * d);
} }
else else
{ {