diff options
author | tagcup <tagcup@yahoo.com> | 2018-05-11 20:14:39 -0400 |
---|---|---|
committer | tagcup <tagcup@yahoo.com> | 2018-05-12 13:05:04 -0400 |
commit | ed7aadcd87a64cde70febc8ee313860e8c67dcaf (patch) | |
tree | 1c9a682a33463feff010a436caf852d4ad4fdcde /core/math/matrix3.cpp | |
parent | 81b1d3c846de263cf843e9e0e9d7c0c0a94f65c8 (diff) | |
download | redot-engine-ed7aadcd87a64cde70febc8ee313860e8c67dcaf.tar.gz |
Add SLERP to Vector{2,3}, optimize Quat's Vector3 rotation.
Also even out Basis and Quat APIs a little.
Diffstat (limited to 'core/math/matrix3.cpp')
-rw-r--r-- | core/math/matrix3.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/core/math/matrix3.cpp b/core/math/matrix3.cpp index b0b05d1ec8..8ee8ccb457 100644 --- a/core/math/matrix3.cpp +++ b/core/math/matrix3.cpp @@ -826,3 +826,16 @@ void Basis::set_diagonal(const Vector3 p_diag) { elements[2][1] = 0; elements[2][2] = p_diag.z; } + +Basis Basis::slerp(const Basis &target, const real_t &t) const { + // TODO: implement this directly without using quaternions to make it more efficient +#ifdef MATH_CHECKS + ERR_FAIL_COND_V(is_rotation() == false, Basis()); + ERR_FAIL_COND_V(target.is_rotation() == false, Basis()); +#endif + + Quat from(*this); + Quat to(target); + + return Basis(from.slerp(to, t)); +} |