From bae19bdf32a79a933f58e9c36b4bb3bf7491a56f Mon Sep 17 00:00:00 2001 From: NathanSweet Date: Thu, 25 Aug 2016 16:03:07 +0200 Subject: [PATCH] Only compute timelinesLast for tracks that need it. --- .../spine/AnimationState.java | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java index f83e8b159..99297e470 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java @@ -461,23 +461,32 @@ public class AnimationState { checkTimelineUsage(entry, entry.timelinesFirst); } - // Compute timelinesLast. Find lowest track with mixing. + // Compute timelinesLast. End with lowest track that has mixingFrom. propertyIDs.clear(); - for (i = n - 1; i >= 0; i--) { + int lowestMixingFrom = n; + for (i = 0; i < n; i++) { TrackEntry entry = tracks.get(i); if (entry == null) continue; if (entry.mixingFrom != null) { - setTimelineUsage(entry, entry.timelinesLast); + lowestMixingFrom = i; + break; + } + } + for (i = n - 1; i >= lowestMixingFrom; i--) { + TrackEntry entry = tracks.get(i); + if (entry == null) continue; + if (entry.mixingFrom != null) { + addTimelineUsage(entry); checkTimelineUsage(entry.mixingFrom, entry.mixingFrom.timelinesLast); } else - setTimelineUsage(entry, entry.timelinesLast); + addTimelineUsage(entry); i--; break; } - for (; i >= 0; i--) { + for (; i >= lowestMixingFrom; i--) { TrackEntry entry = tracks.get(i); if (entry == null) continue; - checkTimelineUsage(entry, entry.timelinesLast); + addTimelineUsage(entry); if (entry.mixingFrom != null) checkTimelineUsage(entry.mixingFrom, entry.mixingFrom.timelinesLast); } } @@ -497,9 +506,16 @@ public class AnimationState { IntSet propertyIDs = this.propertyIDs; Array timelines = entry.animation.timelines; int n = timelines.size; - boolean[] timelinesFirst = usageArray.setSize(n); + boolean[] usage = usageArray.setSize(n); for (int i = 0; i < n; i++) - timelinesFirst[i] = propertyIDs.add(timelines.get(i).getPropertyId()); + usage[i] = propertyIDs.add(timelines.get(i).getPropertyId()); + } + + private void addTimelineUsage (TrackEntry entry) { + IntSet propertyIDs = this.propertyIDs; + Array timelines = entry.animation.timelines; + for (int i = 0, n = timelines.size; i < n; i++) + propertyIDs.add(timelines.get(i).getPropertyId()); } /** Returns the track entry for the animation currently playing on the track, or null. */