From 140335636c34234471fb00fd623842d3934cb39a Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 9 Dec 2024 15:00:59 +0100 Subject: [PATCH] [c] Port of commit 8d058fb: Improved AnimationState behavior when paused. See #2705 --- spine-c/spine-c/src/spine/AnimationState.c | 20 ++++++----- .../spine-cpp/src/spine/AnimationState.cpp | 34 ++++++------------- 2 files changed, 22 insertions(+), 32 deletions(-) diff --git a/spine-c/spine-c/src/spine/AnimationState.c b/spine-c/spine-c/src/spine/AnimationState.c index 5a9c4ac7b..97c7fc00d 100644 --- a/spine-c/spine-c/src/spine/AnimationState.c +++ b/spine-c/spine-c/src/spine/AnimationState.c @@ -350,16 +350,18 @@ int /*boolean*/ _spAnimationState_updateMixingFrom(spAnimationState *self, spTra from->animationLast = from->nextAnimationLast; from->trackLast = from->nextTrackLast; - /* Require mixTime > 0 to ensure the mixing from entry was applied at least once. */ - if (to->mixTime > 0 && to->mixTime >= to->mixDuration) { - /* Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame). */ - if (from->totalAlpha == 0 || to->mixDuration == 0) { - to->mixingFrom = from->mixingFrom; - if (from->mixingFrom != 0) from->mixingFrom->mixingTo = to; - to->interruptAlpha = from->interruptAlpha; - _spEventQueue_end(internal->queue, from); + if (to->nextTrackLast != -1) { // The from entry was applied at least once. + int discard = to->mixTime == 0 && from->mixTime == 0;// Discard the from entry when neither have advanced yet. + if (to->mixTime >= to->mixDuration || discard) { + // Require totalAlpha == 0 to ensure mixing is complete or the transition is a single frame or discarded. + if (from->totalAlpha == 0 || to->mixDuration == 0 || discard) { + to->mixingFrom = from->mixingFrom; + if (from->mixingFrom) from->mixingFrom->mixingTo = to; + to->interruptAlpha = from->interruptAlpha; + _spEventQueue_end(internal->queue, from); + } + return finished; } - return finished; } from->trackTime += delta * from->timeScale; diff --git a/spine-cpp/spine-cpp/src/spine/AnimationState.cpp b/spine-cpp/spine-cpp/src/spine/AnimationState.cpp index 1ae154961..1ffb12ddd 100644 --- a/spine-cpp/spine-cpp/src/spine/AnimationState.cpp +++ b/spine-cpp/spine-cpp/src/spine/AnimationState.cpp @@ -794,31 +794,19 @@ bool AnimationState::updateMixingFrom(TrackEntry *to, float delta) { from->_animationLast = from->_nextAnimationLast; from->_trackLast = from->_nextTrackLast; - // Require mixTime > 0 to ensure the mixing from entry was applied at least once. - if (to->_mixTime > 0 && to->_mixTime >= to->_mixDuration) { - // Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame). - if (from->_totalAlpha == 0 || to->_mixDuration == 0) { - to->_mixingFrom = from->_mixingFrom; - if (from->_mixingFrom != NULL) from->_mixingFrom->_mixingTo = to; - to->_interruptAlpha = from->_interruptAlpha; - _queue->end(from); - } - return finished; - } - - if (to->_nextTrackLast != -1) { // The from entry was applied at least once. - bool discard = to->_mixTime == 0 && from->_mixTime == 0; // Discard the from entry when neither have advanced yet. - if (to->_mixTime >= to->_mixDuration || discard) { - // Require totalAlpha == 0 to ensure mixing is complete or the transition is a single frame or discarded. - if (from->_totalAlpha == 0 || to->_mixDuration == 0 || discard) { - to->_mixingFrom = from->_mixingFrom; - if (from->_mixingFrom) from->_mixingFrom->_mixingTo = to; - to->_interruptAlpha = from->_interruptAlpha; - _queue->end(from); - } - return finished; + if (to->_nextTrackLast != -1) { // The from entry was applied at least once. + bool discard = to->_mixTime == 0 && from->_mixTime == 0;// Discard the from entry when neither have advanced yet. + if (to->_mixTime >= to->_mixDuration || discard) { + // Require totalAlpha == 0 to ensure mixing is complete or the transition is a single frame or discarded. + if (from->_totalAlpha == 0 || to->_mixDuration == 0 || discard) { + to->_mixingFrom = from->_mixingFrom; + if (from->_mixingFrom) from->_mixingFrom->_mixingTo = to; + to->_interruptAlpha = from->_interruptAlpha; + _queue->end(from); } + return finished; } + } from->_trackTime += delta * from->_timeScale; to->_mixTime += delta;