[c] Port of commit 8d058fb: Improved AnimationState behavior when paused. See #2705

This commit is contained in:
Mario Zechner 2024-12-09 15:00:59 +01:00
parent 9bd964514d
commit 140335636c
2 changed files with 22 additions and 32 deletions

View File

@ -350,16 +350,18 @@ int /*boolean*/ _spAnimationState_updateMixingFrom(spAnimationState *self, spTra
from->animationLast = from->nextAnimationLast; from->animationLast = from->nextAnimationLast;
from->trackLast = from->nextTrackLast; from->trackLast = from->nextTrackLast;
/* Require mixTime > 0 to ensure the mixing from entry was applied at least once. */ if (to->nextTrackLast != -1) { // The from entry was applied at least once.
if (to->mixTime > 0 && to->mixTime >= to->mixDuration) { int discard = to->mixTime == 0 && from->mixTime == 0;// Discard the from entry when neither have advanced yet.
/* Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame). */ if (to->mixTime >= to->mixDuration || discard) {
if (from->totalAlpha == 0 || to->mixDuration == 0) { // Require totalAlpha == 0 to ensure mixing is complete or the transition is a single frame or discarded.
to->mixingFrom = from->mixingFrom; if (from->totalAlpha == 0 || to->mixDuration == 0 || discard) {
if (from->mixingFrom != 0) from->mixingFrom->mixingTo = to; to->mixingFrom = from->mixingFrom;
to->interruptAlpha = from->interruptAlpha; if (from->mixingFrom) from->mixingFrom->mixingTo = to;
_spEventQueue_end(internal->queue, from); to->interruptAlpha = from->interruptAlpha;
_spEventQueue_end(internal->queue, from);
}
return finished;
} }
return finished;
} }
from->trackTime += delta * from->timeScale; from->trackTime += delta * from->timeScale;

View File

@ -794,31 +794,19 @@ bool AnimationState::updateMixingFrom(TrackEntry *to, float delta) {
from->_animationLast = from->_nextAnimationLast; from->_animationLast = from->_nextAnimationLast;
from->_trackLast = from->_nextTrackLast; from->_trackLast = from->_nextTrackLast;
// Require mixTime > 0 to ensure the mixing from entry was applied at least once. if (to->_nextTrackLast != -1) { // The from entry was applied at least once.
if (to->_mixTime > 0 && to->_mixTime >= to->_mixDuration) { bool discard = to->_mixTime == 0 && from->_mixTime == 0;// Discard the from entry when neither have advanced yet.
// Require totalAlpha == 0 to ensure mixing is complete, unless mixDuration == 0 (the transition is a single frame). if (to->_mixTime >= to->_mixDuration || discard) {
if (from->_totalAlpha == 0 || to->_mixDuration == 0) { // Require totalAlpha == 0 to ensure mixing is complete or the transition is a single frame or discarded.
to->_mixingFrom = from->_mixingFrom; if (from->_totalAlpha == 0 || to->_mixDuration == 0 || discard) {
if (from->_mixingFrom != NULL) from->_mixingFrom->_mixingTo = to; to->_mixingFrom = from->_mixingFrom;
to->_interruptAlpha = from->_interruptAlpha; if (from->_mixingFrom) from->_mixingFrom->_mixingTo = to;
_queue->end(from); 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;
} }
return finished;
} }
}
from->_trackTime += delta * from->_timeScale; from->_trackTime += delta * from->_timeScale;
to->_mixTime += delta; to->_mixTime += delta;