From ae5ae4ddf2e5787601309c0f25e0494449458e5a Mon Sep 17 00:00:00 2001 From: Davide Tantillo Date: Tue, 10 Dec 2024 14:15:49 +0100 Subject: [PATCH] [haxe] Port of commit 8d058fb: Improved AnimationState behavior when paused. See #2705. --- .../spine/animation/AnimationState.hx | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/spine-haxe/spine-haxe/spine/animation/AnimationState.hx b/spine-haxe/spine-haxe/spine/animation/AnimationState.hx index 489f5df07..a39d94047 100644 --- a/spine-haxe/spine-haxe/spine/animation/AnimationState.hx +++ b/spine-haxe/spine-haxe/spine/animation/AnimationState.hx @@ -148,17 +148,18 @@ class AnimationState { 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); + if (to.nextTrackLast != -1) { // The from entry was applied at least once. + var discard:Bool = 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 != null) from.mixingFrom.mixingTo = to; + to.interruptAlpha = from.interruptAlpha; + queue.end(from); + } + return finished; } - return finished; } from.trackTime += delta * from.timeScale;