summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/raymath.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/raymath.h b/src/raymath.h
index 63fc9696..fd9b620a 100644
--- a/src/raymath.h
+++ b/src/raymath.h
@@ -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