[c][cpp] Port of commit f1e0f0f (#2807)

* [c][cpp] Port of commit f1e0f0f: Fixed animation not being mixed out in some cases. #2786

* [c][cpp] Format.

---------

Co-authored-by: Davide Tantillo <iamdjj@gmail.com>
This commit is contained in:
Luke Ingram 2025-04-09 09:13:39 -04:00 committed by GitHub
parent 092e82d7ae
commit 23233222f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 22 deletions

View File

@ -350,18 +350,16 @@ int /*boolean*/ _spAnimationState_updateMixingFrom(spAnimationState *self, spTra
from->animationLast = from->nextAnimationLast;
from->trackLast = from->nextTrackLast;
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;
// The from entry was applied at least once and the mix is complete.
if (to->nextTrackLast != -1 && to->mixTime >= to->mixDuration) {
// Mixing is complete for all entries before the from entry or the mix is instantaneous.
if (from->totalAlpha == 0 || to->mixDuration == 0) {
to->mixingFrom = from->mixingFrom;
if (from->mixingFrom) from->mixingFrom->mixingTo = to;
to->interruptAlpha = from->interruptAlpha;
_spEventQueue_end(internal->queue, from);
}
return finished;
}
from->trackTime += delta * from->timeScale;

View File

@ -794,18 +794,16 @@ bool AnimationState::updateMixingFrom(TrackEntry *to, float delta) {
from->_animationLast = from->_nextAnimationLast;
from->_trackLast = from->_nextTrackLast;
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;
// The from entry was applied at least once and the mix is complete.
if (to->_nextTrackLast != -1 && to->_mixTime >= to->_mixDuration) {
// Mixing is complete for all entries before the from entry or the mix is instantaneous.
if (from->_totalAlpha == 0 || to->_mixDuration == 0) {
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;