lottie: fix interpolation issue

Handled the case of different numbers
of points in consecutive frames. This
case can occur due to erroneous data
or as a consequence of changing the path
from closed to open and vice versa.

@Issue: https://github.com/thorvg/thorvg/issues/2287
This commit is contained in:
Mira Grudzinska 2024-05-24 23:35:13 +02:00 committed by Hermet Park
parent 03e7c70524
commit 3a8ef78a36

View file

@ -544,7 +544,10 @@ struct LottiePathSet : LottieProperty
else {
frame = frames->data + _bsearch(frames, frameNo);
if (mathEqual(frame->no, frameNo)) path = &frame->value;
else {
else if (frame->value.ptsCnt != (frame + 1)->value.ptsCnt) {
path = &frame->value;
TVGLOG("LOTTIE", "Different numbers of points in consecutive frames - interpolation omitted.");
} else {
t = (frameNo - frame->no) / ((frame + 1)->no - frame->no);
if (frame->interpolator) t = frame->interpolator->progress(t);
if (frame->hold) path = &(frame + ((t < 1.0f) ? 0 : 1))->value;