diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-02-13 10:34:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-13 10:34:13 +0100 |
commit | 72243894681f16c51d8848b4aeea1518d595c2a2 (patch) | |
tree | 419b35e9edf306db96f092118539e4dd667edfe3 /scene | |
parent | aa069a4d31c3eda2a5e194d825e2da795f2cca60 (diff) | |
parent | 865da09871b0242471e7426ed54e9815193df5ae (diff) |
Merge pull request #57954 from TokageItLab/refactor-cubic-interpolate
Implement `cubic_interpolate()` as MathFunc for refactoring
Diffstat (limited to 'scene')
-rw-r--r-- | scene/resources/animation.cpp | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index b6151bccf4..bc533ff022 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -2320,22 +2320,12 @@ Variant Animation::_cubic_interpolate(const Variant &p_pre_a, const Variant &p_a if (vformat == ((1 << Variant::INT) | (1 << Variant::FLOAT)) || vformat == (1 << Variant::FLOAT)) { //mix of real and int + real_t a = p_a; + real_t b = p_b; + real_t pa = p_pre_a; + real_t pb = p_post_b; - real_t p0 = p_pre_a; - real_t p1 = p_a; - real_t p2 = p_b; - real_t p3 = p_post_b; - - real_t t = p_c; - real_t t2 = t * t; - real_t t3 = t2 * t; - - return 0.5f * - ((p1 * 2.0f) + - (-p0 + p2) * t + - (2.0f * p0 - 5.0f * p1 + 4 * p2 - p3) * t2 + - (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3); - + return Math::cubic_interpolate(a, b, pa, pb, p_c); } else if ((vformat & (vformat - 1))) { return p_a; //can't interpolate, mix of types } |