From 7b9a912ff62a95650744f0355ba319789f262285 Mon Sep 17 00:00:00 2001 From: Silc 'Tokage' Renew Date: Tue, 1 Mar 2022 19:09:05 +0900 Subject: [PATCH] fix cubic interpolate when looping 3.x Co-authored-by: robfram --- 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 fd43b995c22..7674284a543 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -1718,11 +1718,19 @@ T Animation::_interpolate(const Vector> &p_keys, float p_time, Interpola case INTERPOLATION_CUBIC: { int pre = idx - 1; if (pre < 0) { - pre = 0; + if (loop && p_loop_wrap) { + pre = len - 1; + } else { + pre = 0; + } } int post = next + 1; if (post >= len) { - post = next; + if (loop && 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);