diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-05-16 23:24:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-16 23:24:56 +0200 |
commit | 36a74696d6751957c1d345ed1c7633d8b68ba827 (patch) | |
tree | 73ca2106917b826f93de8d5048b07db982f6cb79 /core/math/matrix3.cpp | |
parent | 2cf36651b968e99602445678e1fa6ea0adfc078a (diff) | |
parent | ed7aadcd87a64cde70febc8ee313860e8c67dcaf (diff) |
Merge pull request #18804 from tagcup/vec_slerp
Add SLERP to Vector{2,3}, optimize Quat's Vector3 rotation.
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)); +} |