[csharp] Port of commit 30801657: Fixed attachments not being reset when an entry is mixed out. Removed LAST computation.

This commit is contained in:
Harald Csaszar 2020-04-14 20:02:54 +02:00
parent 30801657dd
commit 6c6c25d5d5

View File

@ -66,10 +66,6 @@ namespace Spine {
/// (which affects B and C). Without using D to mix out, A would be applied fully until mixing completes, then snap into /// (which affects B and C). Without using D to mix out, A would be applied fully until mixing completes, then snap into
/// place. /// place.
internal const int HoldMix = 3; internal const int HoldMix = 3;
/// 1) This is the last attachment timeline to set the attachment for a slot.<para />
/// Result: Don't apply this timeline when mixing out. Attachment timelines that are not last are applied when mixing out so
/// any deform timelines are applied and subsequent entries can mix from that deform.
internal const int Last = 4;
internal const int Setup = 1, Current = 2; internal const int Setup = 1, Current = 2;
@ -244,7 +240,7 @@ namespace Spine {
for (int ii = 0; ii < timelineCount; ii++) { for (int ii = 0; ii < timelineCount; ii++) {
Timeline timeline = timelinesItems[ii]; Timeline timeline = timelinesItems[ii];
MixBlend timelineBlend = (timelineMode[ii] & AnimationState.Last - 1) == AnimationState.Subsequent ? blend : MixBlend.Setup; MixBlend timelineBlend = timelineMode[ii] == AnimationState.Subsequent ? blend : MixBlend.Setup;
var rotateTimeline = timeline as RotateTimeline; var rotateTimeline = timeline as RotateTimeline;
if (rotateTimeline != null) if (rotateTimeline != null)
ApplyRotateTimeline(rotateTimeline, skeleton, animationTime, mix, timelineBlend, timelinesRotation, ApplyRotateTimeline(rotateTimeline, skeleton, animationTime, mix, timelineBlend, timelinesRotation,
@ -318,7 +314,7 @@ namespace Spine {
MixDirection direction = MixDirection.Out; MixDirection direction = MixDirection.Out;
MixBlend timelineBlend; MixBlend timelineBlend;
float alpha; float alpha;
switch (timelineMode[i] & AnimationState.Last - 1) { switch (timelineMode[i]) {
case AnimationState.Subsequent: case AnimationState.Subsequent:
if (!drawOrder && timeline is DrawOrderTimeline) continue; if (!drawOrder && timeline is DrawOrderTimeline) continue;
timelineBlend = blend; timelineBlend = blend;
@ -332,7 +328,7 @@ namespace Spine {
timelineBlend = MixBlend.Setup; timelineBlend = MixBlend.Setup;
alpha = alphaHold; alpha = alphaHold;
break; break;
default: default: // HoldMix
timelineBlend = MixBlend.Setup; timelineBlend = MixBlend.Setup;
TrackEntry holdMix = timelineHoldMix[i]; TrackEntry holdMix = timelineHoldMix[i];
alpha = alphaHold * Math.Max(0, 1 - holdMix.mixTime / holdMix.mixDuration); alpha = alphaHold * Math.Max(0, 1 - holdMix.mixTime / holdMix.mixDuration);
@ -344,9 +340,6 @@ namespace Spine {
ApplyRotateTimeline(rotateTimeline, skeleton, animationTime, alpha, timelineBlend, timelinesRotation, ApplyRotateTimeline(rotateTimeline, skeleton, animationTime, alpha, timelineBlend, timelinesRotation,
i << 1, firstFrame); i << 1, firstFrame);
} else if (timeline is AttachmentTimeline) { } else if (timeline is AttachmentTimeline) {
// If not showing attachments: do nothing if this is the last timeline, else apply the timeline so
// subsequent timelines see any deform, but don't set attachmentState to Current.
if (!attachments && (timelineMode[i] & Last) != 0) continue;
ApplyAttachmentTimeline((AttachmentTimeline)timeline, skeleton, animationTime, timelineBlend, attachments); ApplyAttachmentTimeline((AttachmentTimeline)timeline, skeleton, animationTime, timelineBlend, attachments);
} else { } else {
if (drawOrder && timeline is DrawOrderTimeline && timelineBlend == MixBlend.Setup) if (drawOrder && timeline is DrawOrderTimeline && timelineBlend == MixBlend.Setup)
@ -790,16 +783,6 @@ namespace Spine {
entry = entry.mixingTo; entry = entry.mixingTo;
} while (entry != null); } while (entry != null);
} }
// Process in the reverse order that animations are applied.
propertyIDs.Clear();
for (int i = tracks.Count - 1; i >= 0; i--) {
TrackEntry entry = tracksItems[i];
while (entry != null) {
ComputeNotLast(entry);
entry = entry.mixingFrom;
}
}
} }
private void ComputeHold (TrackEntry entry) { private void ComputeHold (TrackEntry entry) {
@ -844,20 +827,6 @@ namespace Spine {
} }
} }
private void ComputeNotLast (TrackEntry entry) {
var timelines = entry.animation.timelines.Items;
int timelinesCount = entry.animation.timelines.Count;
int[] timelineMode = entry.timelineMode.Items;
var propertyIDs = this.propertyIDs;
for (int i = 0; i < timelinesCount; i++) {
if (timelines[i] is AttachmentTimeline) {
AttachmentTimeline timeline = (AttachmentTimeline)timelines[i];
if (propertyIDs.Add(timeline.slotIndex)) timelineMode[i] |= AnimationState.Last;
}
}
}
/// <returns>The track entry for the animation currently playing on the track, or null if no animation is currently playing.</returns> /// <returns>The track entry for the animation currently playing on the track, or null if no animation is currently playing.</returns>
public TrackEntry GetCurrent (int trackIndex) { public TrackEntry GetCurrent (int trackIndex) {
if (trackIndex >= tracks.Count) return null; if (trackIndex >= tracks.Count) return null;