Add check to flip quaternion (#1624)
This commit is contained in:
parent
5902cc6d9b
commit
4e6253b546
1 changed files with 5 additions and 0 deletions
|
@ -1271,6 +1271,11 @@ RMDEF Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount)
|
|||
|
||||
float cosHalfTheta = q1.x*q2.x + q1.y*q2.y + q1.z*q2.z + q1.w*q2.w;
|
||||
|
||||
if (cosHalfTheta < 0) {
|
||||
q2.x = -q2.x; q2.y = -q2.y; q2.z = -q2.z; q2.w = -q2.w;
|
||||
cosHalfTheta = -cosHalfTheta;
|
||||
}
|
||||
|
||||
if (fabs(cosHalfTheta) >= 1.0f) result = q1;
|
||||
else if (cosHalfTheta > 0.95f) result = QuaternionNlerp(q1, q2, amount);
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue