Merge pull request #58344 from TokageItLab/fix-cubic-interpolate-with-loop
This commit is contained in:
commit
0beb721c70
@ -2413,7 +2413,7 @@ T Animation::_interpolate(const Vector<TKey<T>> &p_keys, double p_time, Interpol
|
|||||||
real_t c = 0.0;
|
real_t c = 0.0;
|
||||||
// prepare for all cases of interpolation
|
// prepare for all cases of interpolation
|
||||||
|
|
||||||
if ((loop_mode == LOOP_LINEAR || loop_mode == LOOP_PINGPONG) && p_loop_wrap) {
|
if (loop_mode == LOOP_LINEAR && p_loop_wrap) {
|
||||||
// loop
|
// loop
|
||||||
if (!p_backward) {
|
if (!p_backward) {
|
||||||
// no backward
|
// no backward
|
||||||
@ -2567,12 +2567,20 @@ 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) {
|
||||||
|
if (loop_mode == LOOP_LINEAR && p_loop_wrap) {
|
||||||
|
pre = len - 1;
|
||||||
|
} else {
|
||||||
pre = 0;
|
pre = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
int post = next + 1;
|
int post = next + 1;
|
||||||
if (post >= len) {
|
if (post >= len) {
|
||||||
|
if (loop_mode == LOOP_LINEAR && p_loop_wrap) {
|
||||||
|
post = 0;
|
||||||
|
} else {
|
||||||
post = next;
|
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);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user