From 0e2c41b491905600e4baba87066a131f1ad40ebd Mon Sep 17 00:00:00 2001 From: badlogic Date: Mon, 15 Oct 2018 16:43:26 +0200 Subject: [PATCH] [csharp] Ported 0 timeScale fix, see #1194. --- spine-csharp/src/AnimationState.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/spine-csharp/src/AnimationState.cs b/spine-csharp/src/AnimationState.cs index 777d6e768..8e77c41a5 100644 --- a/spine-csharp/src/AnimationState.cs +++ b/spine-csharp/src/AnimationState.cs @@ -142,7 +142,7 @@ namespace Spine { 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 || to.timeScale == 0)) { + 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; @@ -153,6 +153,13 @@ namespace Spine { return finished; } + // If to has 0 timeScale and is not the first entry, remove the mix and apply it one more time to return to the setup pose. + if (to.timeScale == 0 && to.mixingTo != null) { + to.timeScale = 1; + to.mixTime = 0; + to.mixDuration = 0; + } + from.trackTime += delta * from.timeScale; to.mixTime += delta * to.timeScale; return false; @@ -250,7 +257,7 @@ namespace Spine { bool firstFrame = from.timelinesRotation.Count == 0; if (firstFrame) from.timelinesRotation.Resize(timelines.Count << 1); // from.timelinesRotation.setSize var timelinesRotation = from.timelinesRotation.Items; - + from.totalAlpha = 0; for (int i = 0; i < timelineCount; i++) { Timeline timeline = timelinesItems[i]; @@ -507,7 +514,7 @@ namespace Spine { /// for a track. If the track is empty, it is equivalent to calling . /// /// delay Seconds to begin this animation after the start of the previous animation. If <= 0, uses the duration of the - /// previous track entry minus any mix duration plus the specifieddelay.If the previous entry is + /// previous track entry minus any mix duration plus the specifieddelay.If the previous entry is /// looping, its next loop completion is used instead of the duration. /// /// A track entry to allow further customization of animation playback. References to the track entry must not be kept @@ -897,7 +904,7 @@ namespace Spine { public float MixDuration { get { return mixDuration; } set { mixDuration = value; } } /// - /// Controls how properties keyed in the animation are mixed with lower tracks. Defaults to {@link MixBlend#replace}, which + /// Controls how properties keyed in the animation are mixed with lower tracks. Defaults to {@link MixBlend#replace}, which /// replaces the values from the lower tracks with the animation values. {@link MixBlend#add} adds the animation values to /// the values from the lower tracks. /// @@ -914,9 +921,9 @@ namespace Spine { /// /// If true, when mixing from the previous animation to this animation, the previous animation is applied as normal instead of being mixed out. - /// + /// /// When mixing between animations that key the same property, if a lower track also keys that property then the value will briefly dip toward the lower track value during the mix. This happens because the first animation mixes from 100% to 0% while the second animation mixes from 0% to 100%. Setting HoldPrevious to true applies the first animation at 100% during the mix so the lower track value is overwritten. Such dipping does not occur on the lowest track which keys the property, only when a higher track also keys the property. - /// + /// /// Snapping will occur if HoldPrevious is true and this animation does not key all the same properties as the previous animation. /// public bool HoldPrevious { get { return holdPrevious; } set { holdPrevious = value; } }