This commit is contained in:
Roberto F. Arroyo 2021-11-11 02:05:20 -03:00 committed by GitHub
commit a11ba44409
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2568,11 +2568,19 @@ T Animation::_interpolate(const Vector<TKey<T>> &p_keys, double p_time, Interpol
case INTERPOLATION_CUBIC: { case INTERPOLATION_CUBIC: {
int pre = idx - 1; int pre = idx - 1;
if (pre < 0) { if (pre < 0) {
pre = 0; if (p_loop_wrap) {
pre = len - 1;
} else {
pre = 0;
}
} }
int post = next + 1; int post = next + 1;
if (post >= len) { 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); return _cubic_interpolate(p_keys[pre].value, p_keys[idx].value, p_keys[next].value, p_keys[post].value, c);