[cpp] Fixes completion event firing for 0 duration animations. See #1112.

This commit is contained in:
badlogic 2018-05-16 11:52:28 +02:00
parent eb69071a0a
commit a3a0648ce7
2 changed files with 10 additions and 8 deletions

View File

@ -879,10 +879,12 @@ void AnimationState::queueEvents(TrackEntry *entry, float animationTime) {
} }
// Queue complete if completed a loop iteration or the animation. // Queue complete if completed a loop iteration or the animation.
if (entry->_loop ? (trackLastWrapped > MathUtil::fmod(entry->_trackTime, duration)) : ( bool complete = false;
animationTime >= animationEnd && entry->_animationLast < animationEnd)) { if (entry->_loop)
_queue->complete(entry); complete = duration == 0 || (trackLastWrapped > MathUtil::fmod(entry->_trackTime, duration));
} else
complete = animationTime >= animationEnd && entry->_animationLast < animationEnd;
if (complete) _queue->complete(entry);
// Queue events after complete. // Queue events after complete.
for (; i < n; ++i) { for (; i < n; ++i) {

View File

@ -455,10 +455,10 @@ int main () {
DebugExtension dbgExtension; DebugExtension dbgExtension;
SpineExtension::setInstance(&dbgExtension); SpineExtension::setInstance(&dbgExtension);
// testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor.atlas", 0.5f); testcase(raptor, "data/raptor-pro.json", "data/raptor-pro.skel", "data/raptor.atlas", 0.5f);
// testcase(test, "data/tank-pro.json", "data/tank-pro.skel", "data/tank.atlas", 1.0f); testcase(test, "data/tank-pro.json", "data/tank-pro.skel", "data/tank.atlas", 1.0f);
// testcase(spineboy, "data/spineboy-ess.json", "data/spineboy-ess.skel", "data/spineboy.atlas", 0.6f); testcase(spineboy, "data/spineboy-ess.json", "data/spineboy-ess.skel", "data/spineboy.atlas", 0.6f);
// testcase(owl, "data/owl-pro.json", "data/owl-pro.skel", "data/owl.atlas", 0.5f); testcase(owl, "data/owl-pro.json", "data/owl-pro.skel", "data/owl.atlas", 0.5f);
testcase(coin, "data/coin-pro.json", "data/coin-pro.skel", "data/coin.atlas", 0.5f); testcase(coin, "data/coin-pro.json", "data/coin-pro.skel", "data/coin.atlas", 0.5f);
testcase(vine, "data/vine-pro.json", "data/vine-pro.skel", "data/vine.atlas", 0.5f); testcase(vine, "data/vine-pro.json", "data/vine-pro.skel", "data/vine.atlas", 0.5f);
testcase(tank, "data/tank-pro.json", "data/tank-pro.skel", "data/tank.atlas", 0.2f); testcase(tank, "data/tank-pro.json", "data/tank-pro.skel", "data/tank.atlas", 0.2f);