quaternion: revert elimination of linear case of slerp
We were generating non-finite results for some cases.
This commit is contained in:
parent
33dd89e465
commit
9cd6a60134
@ -118,17 +118,19 @@ cruft::slerp (quaternion<T> a, quaternion<T> b, T t)
|
||||
b = -b;
|
||||
}
|
||||
|
||||
// Calculate coefficients.
|
||||
//
|
||||
// We previously used a linear interpolation when cosine was almost 1, but
|
||||
// it tended to trigger assertions for normalised quaternions; feel free to
|
||||
// change this back, but at this point performance isn't the most prominent
|
||||
// concern.
|
||||
T const omega = std::acos (cosine); // extract theta from dot product's cos theta
|
||||
T const sine = std::sin (omega);
|
||||
// Calculate coefficients
|
||||
T p, q;
|
||||
if (T(0.999999999f) > cosine) {
|
||||
T omega = std::acos (cosine); // extract theta from dot product's cos theta
|
||||
T sine = std::sin (omega);
|
||||
|
||||
T const p = std::sin ((1 - t) * omega) / sine;
|
||||
T const q = std::sin ( t * omega) / sine;
|
||||
p = std::sin ((1 - t) * omega) / sine;
|
||||
q = std::sin ( t * omega) / sine;
|
||||
} else {
|
||||
// Very close, do linear interp (because it's faster)
|
||||
p = 1 - t;
|
||||
q = t;
|
||||
}
|
||||
|
||||
return a * p + b * q;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user