From facae4cb1264e3fa0f4036e2fb29e564878ee9f7 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 7 Apr 2017 23:11:13 +0800 Subject: [PATCH] [csharp] Match fewer ifs for mixAlpha fix. https://github.com/EsotericSoftware/spine-runtimes/commit/f8ea8e99ca3e822f9647ededbc5fdde5966e90aa --- spine-csharp/src/AnimationState.cs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/spine-csharp/src/AnimationState.cs b/spine-csharp/src/AnimationState.cs index 5511b89ae..e9c587815 100644 --- a/spine-csharp/src/AnimationState.cs +++ b/spine-csharp/src/AnimationState.cs @@ -413,22 +413,22 @@ namespace Spine { //from.timelinesRotation.Clear(); var mixingFrom = from.mixingFrom; - float mixProgress = from.mixTime / from.mixDuration; + if (mixingFrom != null && from.mixDuration > 0) { - // A mix was interrupted, mix from the closest animation. - if (!multipleMixing && mixProgress < 0.5f && mixingFrom.animation != AnimationState.EmptyAnimation) { - current.mixingFrom = mixingFrom; - mixingFrom.mixingFrom = from; - mixingFrom.mixTime = from.mixDuration - from.mixTime; - mixingFrom.mixDuration = from.mixDuration; - from.mixingFrom = null; - from = mixingFrom; - } + if (multipleMixing) { + // The interrupted mix will mix out from its current percentage to zero. + current.mixAlpha *= Math.Min(from.mixTime / from.mixDuration, 1); + } else { + // A mix was interrupted, mix from the closest animation. + if (from.mixTime / from.mixDuration < 0.5f && mixingFrom.animation != AnimationState.EmptyAnimation) { + current.mixingFrom = mixingFrom; + mixingFrom.mixingFrom = from; + mixingFrom.mixTime = from.mixDuration - from.mixTime; + mixingFrom.mixDuration = from.mixDuration; + from.mixingFrom = null; + from = mixingFrom; + } - // The interrupted mix will mix out from its current percentage to zero. - if (multipleMixing) current.mixAlpha *= Math.Min(mixProgress, 1); - - if (!multipleMixing) { from.mixAlpha = 0; from.mixTime = 0; from.mixDuration = 0; @@ -650,7 +650,7 @@ namespace Spine { var timelinesItems = timelines.Items; for (int ii = 0, nn = timelines.Count; ii < nn; ii++) propertyIDs.Add(timelinesItems[ii].PropertyId); - + entry = entry.mixingFrom; while (entry != null) { CheckTimelinesUsage(entry, entry.timelinesLast);