diff options
author | reduz <reduzio@gmail.com> | 2021-10-20 20:42:22 -0300 |
---|---|---|
committer | reduz <reduzio@gmail.com> | 2021-10-21 18:27:34 -0300 |
commit | a69541da4cf156ed00de7ed10887a1fc57dcbd14 (patch) | |
tree | f1345855da165570bd81c4aa2c3a71ab63a4ada2 /core/math/quaternion.cpp | |
parent | 9c9ec63e1dbd33cace4a988783f1130b4c3f06ad (diff) |
Implement Animation Compression
Roughly based on https://github.com/godotengine/godot-proposals/issues/3375 (used format is slightly different).
* Implement bitwidth based animation compression (see animation.h for format).
* Can compress imported animations up to 10 times.
* Compression format opens the door to streaming.
* Works transparently (happens all inside animation.h)
Diffstat (limited to 'core/math/quaternion.cpp')
-rw-r--r-- | core/math/quaternion.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/core/math/quaternion.cpp b/core/math/quaternion.cpp index 3f1d2c58e5..a29a70c1f0 100644 --- a/core/math/quaternion.cpp +++ b/core/math/quaternion.cpp @@ -189,6 +189,15 @@ Quaternion::operator String() const { return "(" + String::num_real(x, false) + ", " + String::num_real(y, false) + ", " + String::num_real(z, false) + ", " + String::num_real(w, false) + ")"; } +Vector3 Quaternion::get_axis() const { + real_t r = ((real_t)1) / Math::sqrt(1 - w * w); + return Vector3(x * r, y * r, z * r); +} + +float Quaternion::get_angle() const { + return 2 * Math::acos(w); +} + Quaternion::Quaternion(const Vector3 &p_axis, real_t p_angle) { #ifdef MATH_CHECKS ERR_FAIL_COND_MSG(!p_axis.is_normalized(), "The axis Vector3 must be normalized."); |