Merge pull request #58651 from TokageItLab/fix-cubic-interpolate-3.x

This commit is contained in:
Rémi Verschelde 2022-03-04 12:26:46 +01:00 committed by GitHub
commit eb3f0f50b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -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);