From 067368e2e1a74f9358f2437504d8ab2dad4f1535 Mon Sep 17 00:00:00 2001 From: robfram Date: Tue, 9 Nov 2021 19:15:54 +0100 Subject: [PATCH] Reduce cubic interpolated animation hitch --- scene/resources/animation.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 71d2774335..15a96c5304 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -2512,11 +2512,19 @@ T Animation::_interpolate(const Vector> &p_keys, double p_time, Interpol case INTERPOLATION_CUBIC: { int pre = idx - 1; if (pre < 0) { - pre = 0; + if (p_loop_wrap) { + pre = len - 1; + } else { + pre = 0; + } } int post = next + 1; if (post >= len) { - post = next; + if (p_loop_wrap) { + post = 0; + } else { + post = next; + } } return _cubic_interpolate(p_keys[pre].value, p_keys[idx].value, p_keys[next].value, p_keys[post].value, c);