Skip to content

Commit

Permalink
fix cubic interpolate when looping 3.x
Browse files Browse the repository at this point in the history
Co-authored-by: robfram <robfram@gmail.com>
  • Loading branch information
TokageItLab and robfram committed Mar 1, 2022
1 parent 29d78f2 commit 7b9a912
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions scene/resources/animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1718,11 +1718,19 @@ T Animation::_interpolate(const Vector<TKey<T>> &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);
Expand Down

0 comments on commit 7b9a912

Please sign in to comment.