summaryrefslogtreecommitdiff
path: root/thirdparty/embree/common/math/quaternion.h
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-11-25 14:05:19 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-11-25 14:05:19 +0100
commita9fbf3718d4f8455dee1ebad05374d7baf714370 (patch)
treeb47259851d787776d4a6b11774bc9207aafe200f /thirdparty/embree/common/math/quaternion.h
parentcfaf2f168f233a7183a65d273085789fc47883ff (diff)
parent5e4158eb4869427ac13a0fe57e9b688ea4c3b0f1 (diff)
Merge pull request #69144 from DeeJayLSP/update_embree
Update embree to 3.13.5
Diffstat (limited to 'thirdparty/embree/common/math/quaternion.h')
-rw-r--r--thirdparty/embree/common/math/quaternion.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/thirdparty/embree/common/math/quaternion.h b/thirdparty/embree/common/math/quaternion.h
index 080800efcd..78efccda72 100644
--- a/thirdparty/embree/common/math/quaternion.h
+++ b/thirdparty/embree/common/math/quaternion.h
@@ -242,13 +242,17 @@ namespace embree
T cosTheta = dot(q0, q1_);
QuaternionT<T> q1 = select(cosTheta < 0.f, -q1_, q1_);
cosTheta = select(cosTheta < 0.f, -cosTheta, cosTheta);
- if (unlikely(all(cosTheta > 0.9995f))) {
- return normalize(lerp(q0, q1, t));
- }
+
+ // spherical linear interpolation
const T phi = t * fastapprox::acos(cosTheta);
T sinPhi, cosPhi;
fastapprox::sincos(phi, sinPhi, cosPhi);
QuaternionT<T> qperp = sinPhi * normalize(msub(cosTheta, q0, q1));
- return msub(cosPhi, q0, qperp);
+ QuaternionT<T> qslerp = msub(cosPhi, q0, qperp);
+
+ // regular linear interpolation as fallback
+ QuaternionT<T> qlerp = normalize(lerp(q0, q1, t));
+
+ return select(cosTheta > 0.9995f, qlerp, qslerp);
}
}