diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java index 189ba55fc..28e04b87b 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Animation.java @@ -66,8 +66,9 @@ public class Animation { this.timelines = timelines; timelineIds.clear(); + Object[] items = timelines.items; for (int i = 0, n = timelines.size; i < n; i++) - timelineIds.addAll(timelines.get(i).getPropertyIds()); + timelineIds.addAll(((Timeline)items[i]).getPropertyIds()); } /** Returns true if this animation contains a timeline with any of the specified property IDs. */ @@ -1361,25 +1362,25 @@ public class Animation { public void apply (Skeleton skeleton, float lastTime, float time, @Null Array events, float alpha, MixBlend blend, MixDirection direction) { - Array drawOrder = skeleton.drawOrder; - Array slots = skeleton.slots; + Object[] drawOrder = skeleton.drawOrder.items; if (direction == out) { - if (blend == setup) arraycopy(slots.items, 0, drawOrder.items, 0, slots.size); + if (blend == setup) arraycopy(skeleton.slots.items, 0, drawOrder, 0, skeleton.slots.size); return; } float[] frames = this.frames; if (time < frames[0]) { // Time is before first frame. - if (blend == setup || blend == first) arraycopy(slots.items, 0, drawOrder.items, 0, slots.size); + if (blend == setup || blend == first) arraycopy(skeleton.slots.items, 0, drawOrder, 0, skeleton.slots.size); return; } int[] drawOrderToSetupIndex = drawOrders[search(frames, time)]; if (drawOrderToSetupIndex == null) - arraycopy(slots.items, 0, drawOrder.items, 0, slots.size); + arraycopy(skeleton.slots.items, 0, drawOrder, 0, skeleton.slots.size); else { + Object[] slots = skeleton.slots.items; for (int i = 0, n = drawOrderToSetupIndex.length; i < n; i++) - drawOrder.set(i, slots.get(drawOrderToSetupIndex[i])); + drawOrder[i] = slots[drawOrderToSetupIndex[i]]; } } } 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 0889cd9b7..a5d79fcb6 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/AnimationState.java @@ -112,8 +112,9 @@ public class AnimationState { /** Increments each track entry {@link TrackEntry#getTrackTime()}, setting queued animations as current if needed. */ public void update (float delta) { delta *= timeScale; - for (int i = 0, n = tracks.size; i < n; i++) { - TrackEntry current = tracks.get(i); + Object[] tracks = this.tracks.items; + for (int i = 0, n = this.tracks.size; i < n; i++) { + TrackEntry current = (TrackEntry)tracks[i]; if (current == null) continue; current.animationLast = current.nextAnimationLast; @@ -145,7 +146,7 @@ public class AnimationState { } } else if (current.trackLast >= current.trackEnd && current.mixingFrom == null) { // Clear the track when there is no next entry, the track end time is reached, and there is no mixingFrom. - tracks.set(i, null); + tracks[i] = null; queue.end(current); disposeNext(current); continue; @@ -203,8 +204,9 @@ public class AnimationState { Array events = this.events; boolean applied = false; - for (int i = 0, n = tracks.size; i < n; i++) { - TrackEntry current = tracks.get(i); + Object[] tracks = this.tracks.items; + for (int i = 0, n = this.tracks.size; i < n; i++) { + TrackEntry current = (TrackEntry)tracks[i]; if (current == null || current.delay > 0) continue; applied = true; @@ -459,10 +461,10 @@ public class AnimationState { float trackLastWrapped = entry.trackLast % duration; // Queue events before complete. - Array events = this.events; - int i = 0, n = events.size; + Object[] events = this.events.items; + int i = 0, n = this.events.size; for (; i < n; i++) { - Event event = events.get(i); + Event event = (Event)events[i]; if (event.time < trackLastWrapped) break; if (event.time > animationEnd) continue; // Discard events outside animation start/end. queue.event(entry, event); @@ -478,9 +480,9 @@ public class AnimationState { // Queue events after complete. for (; i < n; i++) { - Event event = events.get(i); + Event event = (Event)events[i]; if (event.time < animationStart) continue; // Discard events outside animation start/end. - queue.event(entry, events.get(i)); + queue.event(entry, event); } } @@ -681,8 +683,9 @@ public class AnimationState { public void setEmptyAnimations (float mixDuration) { boolean oldDrainDisabled = queue.drainDisabled; queue.drainDisabled = true; - for (int i = 0, n = tracks.size; i < n; i++) { - TrackEntry current = tracks.get(i); + Object[] tracks = this.tracks.items; + for (int i = 0, n = this.tracks.size; i < n; i++) { + TrackEntry current = (TrackEntry)tracks[i]; if (current != null) setEmptyAnimation(current.trackIndex, mixDuration); } queue.drainDisabled = oldDrainDisabled; @@ -740,8 +743,10 @@ public class AnimationState { // Process in the order that animations are applied. propertyIds.clear(2048); - for (int i = 0, n = tracks.size; i < n; i++) { - TrackEntry entry = tracks.get(i); + int n = tracks.size; + Object[] tracks = this.tracks.items; + for (int i = 0; i < n; i++) { + TrackEntry entry = (TrackEntry)tracks[i]; if (entry == null) continue; while (entry.mixingFrom != null) // Move to last entry, then iterate in reverse. entry = entry.mixingFrom; @@ -753,8 +758,8 @@ public class AnimationState { // Process in the reverse order that animations are applied. propertyIds.clear(2048); - for (int i = tracks.size - 1; i >= 0; i--) { - TrackEntry entry = tracks.get(i); + for (int i = n - 1; i >= 0; i--) { + TrackEntry entry = (TrackEntry)tracks[i]; while (entry != null) { computeNotLast(entry); entry = entry.mixingFrom; @@ -877,8 +882,9 @@ public class AnimationState { public String toString () { StringBuilder buffer = new StringBuilder(64); - for (int i = 0, n = tracks.size; i < n; i++) { - TrackEntry entry = tracks.get(i); + Object[] tracks = this.tracks.items; + for (int i = 0, n = this.tracks.size; i < n; i++) { + TrackEntry entry = (TrackEntry)tracks[i]; if (entry == null) continue; if (buffer.length() > 0) buffer.append(", "); buffer.append(entry.toString()); @@ -1269,11 +1275,11 @@ public class AnimationState { if (drainDisabled) return; // Not reentrant. drainDisabled = true; - Array objects = this.objects; + Object[] objects = this.objects.items; SnapshotArray listenersArray = AnimationState.this.listeners; - for (int i = 0; i < objects.size; i += 2) { - EventType type = (EventType)objects.get(i); - TrackEntry entry = (TrackEntry)objects.get(i + 1); + for (int i = 0; i < this.objects.size; i += 2) { + EventType type = (EventType)objects[i]; + TrackEntry entry = (TrackEntry)objects[i + 1]; int listenersCount = listenersArray.size; Object[] listeners = listenersArray.begin(); switch (type) { @@ -1304,7 +1310,7 @@ public class AnimationState { ((AnimationStateListener)listeners[ii]).complete(entry); break; case event: - Event event = (Event)objects.get(i++ + 2); + Event event = (Event)objects[i++ + 2]; if (entry.listener != null) entry.listener.event(entry, event); for (int ii = 0; ii < listenersCount; ii++) ((AnimationStateListener)listeners[ii]).event(entry, event); diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/IkConstraint.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/IkConstraint.java index f3402a0f0..5774c64d5 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/IkConstraint.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/IkConstraint.java @@ -86,13 +86,13 @@ public class IkConstraint implements Updatable { public void update () { Bone target = this.target; - Array bones = this.bones; - switch (bones.size) { + Object[] bones = this.bones.items; + switch (this.bones.size) { case 1: - apply(bones.first(), target.worldX, target.worldY, compress, stretch, data.uniform, mix); + apply((Bone)bones[0], target.worldX, target.worldY, compress, stretch, data.uniform, mix); break; case 2: - apply(bones.first(), bones.get(1), target.worldX, target.worldY, bendDirection, stretch, softness, mix); + apply((Bone)bones[0], (Bone)bones[1], target.worldX, target.worldY, bendDirection, stretch, softness, mix); break; } } diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java index 02026fe8b..301af5bd1 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skeleton.java @@ -68,22 +68,23 @@ public class Skeleton { this.data = data; bones = new Array(data.bones.size); + Object[] bones = this.bones.items; for (BoneData boneData : data.bones) { Bone bone; if (boneData.parent == null) bone = new Bone(boneData, this, null); else { - Bone parent = bones.get(boneData.parent.index); + Bone parent = (Bone)bones[boneData.parent.index]; bone = new Bone(boneData, this, parent); parent.children.add(bone); } - bones.add(bone); + this.bones.add(bone); } slots = new Array(data.slots.size); drawOrder = new Array(data.slots.size); for (SlotData slotData : data.slots) { - Bone bone = bones.get(slotData.boneData.index); + Bone bone = (Bone)bones[slotData.boneData.index]; Slot slot = new Slot(slotData, bone); slots.add(slot); drawOrder.add(slot); @@ -253,17 +254,17 @@ public class Skeleton { Attachment attachment = slot.attachment; if (attachment instanceof PathAttachment) sortPathConstraintAttachment(attachment, slotBone); - Array constrained = constraint.bones; - int boneCount = constrained.size; + Object[] constrained = constraint.bones.items; + int boneCount = constraint.bones.size; for (int i = 0; i < boneCount; i++) - sortBone(constrained.get(i)); + sortBone((Bone)constrained[i]); updateCache.add(constraint); for (int i = 0; i < boneCount; i++) - sortReset(constrained.get(i).children); + sortReset(((Bone)constrained[i]).children); for (int i = 0; i < boneCount; i++) - constrained.get(i).sorted = true; + ((Bone)constrained[i]).sorted = true; } private void sortTransformConstraint (TransformConstraint constraint) { @@ -273,25 +274,25 @@ public class Skeleton { sortBone(constraint.target); - Array constrained = constraint.bones; - int boneCount = constrained.size; + Object[] constrained = constraint.bones.items; + int boneCount = constraint.bones.size; if (constraint.data.local) { for (int i = 0; i < boneCount; i++) { - Bone child = constrained.get(i); + Bone child = (Bone)constrained[i]; sortBone(child.parent); if (!updateCache.contains(child, true)) updateCacheReset.add(child); } } else { for (int i = 0; i < boneCount; i++) - sortBone(constrained.get(i)); + sortBone((Bone)constrained[i]); } updateCache.add(constraint); for (int i = 0; i < boneCount; i++) - sortReset(constrained.get(i).children); + sortReset(((Bone)constrained[i]).children); for (int i = 0; i < boneCount; i++) - constrained.get(i).sorted = true; + ((Bone)constrained[i]).sorted = true; } private void sortPathConstraintAttachment (Skin skin, int slotIndex, Bone slotBone) { @@ -308,12 +309,12 @@ public class Skeleton { if (pathBones == null) sortBone(slotBone); else { - Array bones = this.bones; + Object[] bones = this.bones.items; for (int i = 0, n = pathBones.length; i < n;) { int nn = pathBones[i++]; nn += i; while (i < nn) - sortBone(bones.get(pathBones[i++])); + sortBone((Bone)bones[pathBones[i++]]); } } } @@ -327,8 +328,9 @@ public class Skeleton { } private void sortReset (Array bones) { + Object[] items = bones.items; for (int i = 0, n = bones.size; i < n; i++) { - Bone bone = bones.get(i); + Bone bone = (Bone)items[i]; if (!bone.active) continue; if (bone.sorted) sortReset(bone.children); bone.sorted = false; @@ -343,9 +345,9 @@ public class Skeleton { // This partial update avoids computing the world transform for constrained bones when 1) the bone is not updated // before the constraint, 2) the constraint only needs to access the applied local transform, and 3) the constraint calls // updateWorldTransform. - Array updateCacheReset = this.updateCacheReset; - for (int i = 0, n = updateCacheReset.size; i < n; i++) { - Bone bone = updateCacheReset.get(i); + Object[] updateCacheReset = this.updateCacheReset.items; + for (int i = 0, n = this.updateCacheReset.size; i < n; i++) { + Bone bone = (Bone)updateCacheReset[i]; bone.ax = bone.x; bone.ay = bone.y; bone.arotation = bone.rotation; @@ -355,9 +357,9 @@ public class Skeleton { bone.ashearY = bone.shearY; bone.appliedValid = true; } - Array updateCache = this.updateCache; - for (int i = 0, n = updateCache.size; i < n; i++) - updateCache.get(i).update(); + Object[] updateCache = this.updateCache.items; + for (int i = 0, n = this.updateCache.size; i < n; i++) + ((Updatable)updateCache[i]).update(); } /** Temporarily sets the root bone as a child of the specified bone, then updates the world transform for each bone and applies @@ -367,12 +369,13 @@ public class Skeleton { * Runtimes Guide. */ public void updateWorldTransform (Bone parent) { if (parent == null) throw new IllegalArgumentException("parent cannot be null."); - // This partial update avoids computing the world transform for constrained bones when 1) the bone is not updated - // before the constraint, 2) the constraint only needs to access the applied local transform, and 3) the constraint calls - // updateWorldTransform. - Array updateCacheReset = this.updateCacheReset; - for (int i = 0, n = updateCacheReset.size; i < n; i++) { - Bone bone = updateCacheReset.get(i); + // This partial update avoids computing the world transform for constrained bones when: + // 1) the bone is not updated before the constraint, + // 2) the constraint only needs to access the applied local transform, and + // 3) the constraint calls updateWorldTransform. + Object[] updateCacheReset = this.updateCacheReset.items; + for (int i = 0, n = this.updateCacheReset.size; i < n; i++) { + Bone bone = (Bone)updateCacheReset[i]; bone.ax = bone.x; bone.ay = bone.y; bone.arotation = bone.rotation; @@ -400,9 +403,9 @@ public class Skeleton { rootBone.d = (pc * lb + pd * ld) * scaleY; // Update everything except root bone. - Array updateCache = this.updateCache; - for (int i = 0, n = updateCache.size; i < n; i++) { - Updatable updatable = updateCache.get(i); + Object[] updateCache = this.updateCache.items; + for (int i = 0, n = this.updateCache.size; i < n; i++) { + Updatable updatable = (Updatable)updateCache[i]; if (updatable != rootBone) updatable.update(); } } @@ -415,13 +418,13 @@ public class Skeleton { /** Sets the bones and constraints to their setup pose values. */ public void setBonesToSetupPose () { - Array bones = this.bones; - for (int i = 0, n = bones.size; i < n; i++) - bones.get(i).setToSetupPose(); + Object[] bones = this.bones.items; + for (int i = 0, n = this.bones.size; i < n; i++) + ((Bone)bones[i]).setToSetupPose(); - Array ikConstraints = this.ikConstraints; - for (int i = 0, n = ikConstraints.size; i < n; i++) { - IkConstraint constraint = ikConstraints.get(i); + Object[] ikConstraints = this.ikConstraints.items; + for (int i = 0, n = this.ikConstraints.size; i < n; i++) { + IkConstraint constraint = (IkConstraint)ikConstraints[i]; constraint.mix = constraint.data.mix; constraint.softness = constraint.data.softness; constraint.bendDirection = constraint.data.bendDirection; @@ -429,9 +432,9 @@ public class Skeleton { constraint.stretch = constraint.data.stretch; } - Array transformConstraints = this.transformConstraints; - for (int i = 0, n = transformConstraints.size; i < n; i++) { - TransformConstraint constraint = transformConstraints.get(i); + Object[] transformConstraints = this.transformConstraints.items; + for (int i = 0, n = this.transformConstraints.size; i < n; i++) { + TransformConstraint constraint = (TransformConstraint)transformConstraints[i]; TransformConstraintData data = constraint.data; constraint.rotateMix = data.rotateMix; constraint.translateMix = data.translateMix; @@ -439,9 +442,9 @@ public class Skeleton { constraint.shearMix = data.shearMix; } - Array pathConstraints = this.pathConstraints; - for (int i = 0, n = pathConstraints.size; i < n; i++) { - PathConstraint constraint = pathConstraints.get(i); + Object[] pathConstraints = this.pathConstraints.items; + for (int i = 0, n = this.pathConstraints.size; i < n; i++) { + PathConstraint constraint = (PathConstraint)pathConstraints[i]; PathConstraintData data = constraint.data; constraint.position = data.position; constraint.spacing = data.spacing; @@ -452,10 +455,11 @@ public class Skeleton { /** Sets the slots and draw order to their setup pose values. */ public void setSlotsToSetupPose () { - Array slots = this.slots; - arraycopy(slots.items, 0, drawOrder.items, 0, slots.size); - for (int i = 0, n = slots.size; i < n; i++) - slots.get(i).setToSetupPose(); + Object[] slots = this.slots.items; + int n = this.slots.size; + arraycopy(slots, 0, drawOrder.items, 0, n); + for (int i = 0; i < n; i++) + ((Slot)slots[i]).setToSetupPose(); } /** The skeleton's setup pose data. */ @@ -483,9 +487,9 @@ public class Skeleton { @Null public Bone findBone (String boneName) { if (boneName == null) throw new IllegalArgumentException("boneName cannot be null."); - Array bones = this.bones; - for (int i = 0, n = bones.size; i < n; i++) { - Bone bone = bones.get(i); + Object[] bones = this.bones.items; + for (int i = 0, n = this.bones.size; i < n; i++) { + Bone bone = (Bone)bones[i]; if (bone.data.name.equals(boneName)) return bone; } return null; @@ -501,9 +505,9 @@ public class Skeleton { @Null public Slot findSlot (String slotName) { if (slotName == null) throw new IllegalArgumentException("slotName cannot be null."); - Array slots = this.slots; - for (int i = 0, n = slots.size; i < n; i++) { - Slot slot = slots.get(i); + Object[] slots = this.slots.items; + for (int i = 0, n = this.slots.size; i < n; i++) { + Slot slot = (Slot)slots[i]; if (slot.data.name.equals(slotName)) return slot; } return null; @@ -550,9 +554,9 @@ public class Skeleton { if (skin != null) newSkin.attachAll(this, skin); else { - Array slots = this.slots; - for (int i = 0, n = slots.size; i < n; i++) { - Slot slot = slots.get(i); + Object[] slots = this.slots.items; + for (int i = 0, n = this.slots.size; i < n; i++) { + Slot slot = (Slot)slots[i]; String name = slot.data.attachmentName; if (name != null) { Attachment attachment = newSkin.getAttachment(i, name); @@ -617,9 +621,9 @@ public class Skeleton { @Null public IkConstraint findIkConstraint (String constraintName) { if (constraintName == null) throw new IllegalArgumentException("constraintName cannot be null."); - Array ikConstraints = this.ikConstraints; - for (int i = 0, n = ikConstraints.size; i < n; i++) { - IkConstraint ikConstraint = ikConstraints.get(i); + Object[] ikConstraints = this.ikConstraints.items; + for (int i = 0, n = this.ikConstraints.size; i < n; i++) { + IkConstraint ikConstraint = (IkConstraint)ikConstraints[i]; if (ikConstraint.data.name.equals(constraintName)) return ikConstraint; } return null; @@ -635,9 +639,9 @@ public class Skeleton { @Null public TransformConstraint findTransformConstraint (String constraintName) { if (constraintName == null) throw new IllegalArgumentException("constraintName cannot be null."); - Array transformConstraints = this.transformConstraints; - for (int i = 0, n = transformConstraints.size; i < n; i++) { - TransformConstraint constraint = transformConstraints.get(i); + Object[] transformConstraints = this.transformConstraints.items; + for (int i = 0, n = this.transformConstraints.size; i < n; i++) { + TransformConstraint constraint = (TransformConstraint)transformConstraints[i]; if (constraint.data.name.equals(constraintName)) return constraint; } return null; @@ -653,9 +657,9 @@ public class Skeleton { @Null public PathConstraint findPathConstraint (String constraintName) { if (constraintName == null) throw new IllegalArgumentException("constraintName cannot be null."); - Array pathConstraints = this.pathConstraints; - for (int i = 0, n = pathConstraints.size; i < n; i++) { - PathConstraint constraint = pathConstraints.get(i); + Object[] pathConstraints = this.pathConstraints.items; + for (int i = 0, n = this.pathConstraints.size; i < n; i++) { + PathConstraint constraint = (PathConstraint)pathConstraints[i]; if (constraint.data.name.equals(constraintName)) return constraint; } return null; @@ -669,10 +673,10 @@ public class Skeleton { if (offset == null) throw new IllegalArgumentException("offset cannot be null."); if (size == null) throw new IllegalArgumentException("size cannot be null."); if (temp == null) throw new IllegalArgumentException("temp cannot be null."); - Array drawOrder = this.drawOrder; + Object[] drawOrder = this.drawOrder.items; float minX = Integer.MAX_VALUE, minY = Integer.MAX_VALUE, maxX = Integer.MIN_VALUE, maxY = Integer.MIN_VALUE; - for (int i = 0, n = drawOrder.size; i < n; i++) { - Slot slot = drawOrder.get(i); + for (int i = 0, n = this.drawOrder.size; i < n; i++) { + Slot slot = (Slot)drawOrder[i]; if (!slot.bone.active) continue; int verticesLength = 0; float[] vertices = null; diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java index 90e794a8d..5b72b13da 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBinary.java @@ -163,16 +163,15 @@ public class SkeletonBinary { Object[] o; // Strings. - input.strings = new Array(n = input.readInt(true)); - o = input.strings.setSize(n); + o = input.strings = new String[n = input.readInt(true)]; for (int i = 0; i < n; i++) o[i] = input.readString(); // Bones. - o = skeletonData.bones.setSize(n = input.readInt(true)); + Object[] bones = skeletonData.bones.setSize(n = input.readInt(true)); for (int i = 0; i < n; i++) { String name = input.readString(); - BoneData parent = i == 0 ? null : skeletonData.bones.get(input.readInt(true)); + BoneData parent = i == 0 ? null : (BoneData)bones[input.readInt(true)]; BoneData data = new BoneData(i, name, parent); data.rotation = input.readFloat(); data.x = input.readFloat() * scale; @@ -185,14 +184,14 @@ public class SkeletonBinary { data.transformMode = TransformMode.values[input.readInt(true)]; data.skinRequired = input.readBoolean(); if (nonessential) Color.rgba8888ToColor(data.color, input.readInt()); - o[i] = data; + bones[i] = data; } // Slots. - o = skeletonData.slots.setSize(n = input.readInt(true)); + Object[] slots = skeletonData.slots.setSize(n = input.readInt(true)); for (int i = 0; i < n; i++) { String slotName = input.readString(); - BoneData boneData = skeletonData.bones.get(input.readInt(true)); + BoneData boneData = (BoneData)bones[input.readInt(true)]; SlotData data = new SlotData(i, slotName, boneData); Color.rgba8888ToColor(data.color, input.readInt()); @@ -201,7 +200,7 @@ public class SkeletonBinary { data.attachmentName = input.readStringRef(); data.blendMode = BlendMode.values[input.readInt(true)]; - o[i] = data; + slots[i] = data; } // IK constraints. @@ -210,10 +209,10 @@ public class SkeletonBinary { IkConstraintData data = new IkConstraintData(input.readString()); data.order = input.readInt(true); data.skinRequired = input.readBoolean(); - Object[] bones = data.bones.setSize(nn = input.readInt(true)); + Object[] constraintBones = data.bones.setSize(nn = input.readInt(true)); for (int ii = 0; ii < nn; ii++) - bones[ii] = skeletonData.bones.get(input.readInt(true)); - data.target = skeletonData.bones.get(input.readInt(true)); + constraintBones[ii] = bones[input.readInt(true)]; + data.target = (BoneData)bones[input.readInt(true)]; data.mix = input.readFloat(); data.softness = input.readFloat() * scale; data.bendDirection = input.readByte(); @@ -229,10 +228,10 @@ public class SkeletonBinary { TransformConstraintData data = new TransformConstraintData(input.readString()); data.order = input.readInt(true); data.skinRequired = input.readBoolean(); - Object[] bones = data.bones.setSize(nn = input.readInt(true)); + Object[] constraintBones = data.bones.setSize(nn = input.readInt(true)); for (int ii = 0; ii < nn; ii++) - bones[ii] = skeletonData.bones.get(input.readInt(true)); - data.target = skeletonData.bones.get(input.readInt(true)); + constraintBones[ii] = bones[input.readInt(true)]; + data.target = (BoneData)bones[input.readInt(true)]; data.local = input.readBoolean(); data.relative = input.readBoolean(); data.offsetRotation = input.readFloat(); @@ -254,10 +253,10 @@ public class SkeletonBinary { PathConstraintData data = new PathConstraintData(input.readString()); data.order = input.readInt(true); data.skinRequired = input.readBoolean(); - Object[] bones = data.bones.setSize(nn = input.readInt(true)); + Object[] constraintBones = data.bones.setSize(nn = input.readInt(true)); for (int ii = 0; ii < nn; ii++) - bones[ii] = skeletonData.bones.get(input.readInt(true)); - data.target = skeletonData.slots.get(input.readInt(true)); + constraintBones[ii] = bones[input.readInt(true)]; + data.target = (SlotData)slots[input.readInt(true)]; data.positionMode = PositionMode.values[input.readInt(true)]; data.spacingMode = SpacingMode.values[input.readInt(true)]; data.rotateMode = RotateMode.values[input.readInt(true)]; @@ -288,8 +287,9 @@ public class SkeletonBinary { // Linked meshes. n = linkedMeshes.size; + Object[] items = linkedMeshes.items; for (int i = 0; i < n; i++) { - LinkedMesh linkedMesh = linkedMeshes.get(i); + LinkedMesh linkedMesh = (LinkedMesh)items[i]; Skin skin = linkedMesh.skin == null ? skeletonData.getDefaultSkin() : skeletonData.findSkin(linkedMesh.skin); if (skin == null) throw new SerializationException("Skin not found: " + linkedMesh.skin); Attachment parent = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent); @@ -343,16 +343,19 @@ public class SkeletonBinary { skin = new Skin("default"); } else { skin = new Skin(input.readStringRef()); - Object[] bones = skin.bones.setSize(input.readInt(true)); + Object[] bones = skin.bones.setSize(input.readInt(true)), items = skeletonData.bones.items; for (int i = 0, n = skin.bones.size; i < n; i++) - bones[i] = skeletonData.bones.get(input.readInt(true)); + bones[i] = items[input.readInt(true)]; + items = skeletonData.ikConstraints.items; for (int i = 0, n = input.readInt(true); i < n; i++) - skin.constraints.add(skeletonData.ikConstraints.get(input.readInt(true))); + skin.constraints.add((ConstraintData)items[input.readInt(true)]); + items = skeletonData.transformConstraints.items; for (int i = 0, n = input.readInt(true); i < n; i++) - skin.constraints.add(skeletonData.transformConstraints.get(input.readInt(true))); + skin.constraints.add((ConstraintData)items[input.readInt(true)]); + items = skeletonData.pathConstraints.items; for (int i = 0, n = input.readInt(true); i < n; i++) - skin.constraints.add(skeletonData.pathConstraints.get(input.readInt(true))); + skin.constraints.add((ConstraintData)items[input.readInt(true)]); skin.constraints.shrink(); slotCount = input.readInt(true); @@ -871,8 +874,9 @@ public class SkeletonBinary { } float duration = 0; + Object[] items = timelines.items; for (int i = 0, n = timelines.size; i < n; i++) - duration = Math.max(duration, timelines.get(i).getDuration()); + duration = Math.max(duration, ((Timeline)items[i]).getDuration()); return new Animation(name, timelines, duration); } @@ -929,7 +933,7 @@ public class SkeletonBinary { static class SkeletonInput extends DataInput { private char[] chars = new char[32]; - Array strings; + String[] strings; public SkeletonInput (FileHandle file) { super(file.read(512)); @@ -938,7 +942,7 @@ public class SkeletonBinary { @Null public String readStringRef () throws IOException { int index = readInt(true); - return index == 0 ? null : strings.get(index - 1); + return index == 0 ? null : strings[index - 1]; } public String readString () throws IOException { diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBounds.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBounds.java index c3cfd1168..f15729812 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBounds.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonBounds.java @@ -57,15 +57,15 @@ public class SkeletonBounds { if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null."); Array boundingBoxes = this.boundingBoxes; Array polygons = this.polygons; - Array slots = skeleton.slots; - int slotCount = slots.size; + Object[] slots = skeleton.slots.items; + int slotCount = skeleton.slots.size; boundingBoxes.clear(); polygonPool.freeAll(polygons); polygons.clear(); for (int i = 0; i < slotCount; i++) { - Slot slot = slots.get(i); + Slot slot = (Slot)slots[i]; if (!slot.bone.active) continue; Attachment attachment = slot.attachment; if (attachment instanceof BoundingBoxAttachment) { @@ -91,9 +91,9 @@ public class SkeletonBounds { private void aabbCompute () { float minX = Integer.MAX_VALUE, minY = Integer.MAX_VALUE, maxX = Integer.MIN_VALUE, maxY = Integer.MIN_VALUE; - Array polygons = this.polygons; - for (int i = 0, n = polygons.size; i < n; i++) { - FloatArray polygon = polygons.get(i); + Object[] polygons = this.polygons.items; + for (int i = 0, n = this.polygons.size; i < n; i++) { + FloatArray polygon = (FloatArray)polygons[i]; float[] vertices = polygon.items; for (int ii = 0, nn = polygon.size; ii < nn; ii += 2) { float x = vertices[ii]; @@ -145,9 +145,9 @@ public class SkeletonBounds { * efficient to only call this method if {@link #aabbContainsPoint(float, float)} returns true. */ @Null public BoundingBoxAttachment containsPoint (float x, float y) { - Array polygons = this.polygons; - for (int i = 0, n = polygons.size; i < n; i++) - if (containsPoint(polygons.get(i), x, y)) return boundingBoxes.get(i); + Object[] polygons = this.polygons.items; + for (int i = 0, n = this.polygons.size; i < n; i++) + if (containsPoint((FloatArray)polygons[i], x, y)) return boundingBoxes.get(i); return null; } @@ -176,9 +176,9 @@ public class SkeletonBounds { * true. */ @Null public BoundingBoxAttachment intersectsSegment (float x1, float y1, float x2, float y2) { - Array polygons = this.polygons; - for (int i = 0, n = polygons.size; i < n; i++) - if (intersectsSegment(polygons.get(i), x1, y1, x2, y2)) return boundingBoxes.get(i); + Object[] polygons = this.polygons.items; + for (int i = 0, n = this.polygons.size; i < n; i++) + if (intersectsSegment((FloatArray)polygons[i], x1, y1, x2, y2)) return boundingBoxes.get(i); return null; } diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonData.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonData.java index c9117d4ad..4ef6ab341 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonData.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonData.java @@ -70,9 +70,9 @@ public class SkeletonData { @Null public BoneData findBone (String boneName) { if (boneName == null) throw new IllegalArgumentException("boneName cannot be null."); - Array bones = this.bones; - for (int i = 0, n = bones.size; i < n; i++) { - BoneData bone = bones.get(i); + Object[] bones = this.bones.items; + for (int i = 0, n = this.bones.size; i < n; i++) { + BoneData bone = (BoneData)bones[i]; if (bone.name.equals(boneName)) return bone; } return null; @@ -90,9 +90,9 @@ public class SkeletonData { @Null public SlotData findSlot (String slotName) { if (slotName == null) throw new IllegalArgumentException("slotName cannot be null."); - Array slots = this.slots; - for (int i = 0, n = slots.size; i < n; i++) { - SlotData slot = slots.get(i); + Object[] slots = this.slots.items; + for (int i = 0, n = this.slots.size; i < n; i++) { + SlotData slot = (SlotData)slots[i]; if (slot.name.equals(slotName)) return slot; } return null; @@ -156,9 +156,9 @@ public class SkeletonData { @Null public Animation findAnimation (String animationName) { if (animationName == null) throw new IllegalArgumentException("animationName cannot be null."); - Array animations = this.animations; - for (int i = 0, n = animations.size; i < n; i++) { - Animation animation = animations.get(i); + Object[] animations = this.animations.items; + for (int i = 0, n = this.animations.size; i < n; i++) { + Animation animation = (Animation)animations[i]; if (animation.name.equals(animationName)) return animation; } return null; @@ -176,9 +176,9 @@ public class SkeletonData { @Null public IkConstraintData findIkConstraint (String constraintName) { if (constraintName == null) throw new IllegalArgumentException("constraintName cannot be null."); - Array ikConstraints = this.ikConstraints; - for (int i = 0, n = ikConstraints.size; i < n; i++) { - IkConstraintData constraint = ikConstraints.get(i); + Object[] ikConstraints = this.ikConstraints.items; + for (int i = 0, n = this.ikConstraints.size; i < n; i++) { + IkConstraintData constraint = (IkConstraintData)ikConstraints[i]; if (constraint.name.equals(constraintName)) return constraint; } return null; @@ -196,9 +196,9 @@ public class SkeletonData { @Null public TransformConstraintData findTransformConstraint (String constraintName) { if (constraintName == null) throw new IllegalArgumentException("constraintName cannot be null."); - Array transformConstraints = this.transformConstraints; - for (int i = 0, n = transformConstraints.size; i < n; i++) { - TransformConstraintData constraint = transformConstraints.get(i); + Object[] transformConstraints = this.transformConstraints.items; + for (int i = 0, n = this.transformConstraints.size; i < n; i++) { + TransformConstraintData constraint = (TransformConstraintData)transformConstraints[i]; if (constraint.name.equals(constraintName)) return constraint; } return null; @@ -216,9 +216,9 @@ public class SkeletonData { @Null public PathConstraintData findPathConstraint (String constraintName) { if (constraintName == null) throw new IllegalArgumentException("constraintName cannot be null."); - Array pathConstraints = this.pathConstraints; - for (int i = 0, n = pathConstraints.size; i < n; i++) { - PathConstraintData constraint = pathConstraints.get(i); + Object[] pathConstraints = this.pathConstraints.items; + for (int i = 0, n = this.pathConstraints.size; i < n; i++) { + PathConstraintData constraint = (PathConstraintData)pathConstraints[i]; if (constraint.name.equals(constraintName)) return constraint; } return null; diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java index c419e9a76..2ad62d83e 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonJson.java @@ -316,8 +316,9 @@ public class SkeletonJson { } // Linked meshes. + Object[] items = linkedMeshes.items; for (int i = 0, n = linkedMeshes.size; i < n; i++) { - LinkedMesh linkedMesh = linkedMeshes.get(i); + LinkedMesh linkedMesh = (LinkedMesh)items[i]; Skin skin = linkedMesh.skin == null ? skeletonData.getDefaultSkin() : skeletonData.findSkin(linkedMesh.skin); if (skin == null) throw new SerializationException("Skin not found: " + linkedMesh.skin); Attachment parent = skin.getAttachment(linkedMesh.slotIndex, linkedMesh.parent); @@ -845,8 +846,9 @@ public class SkeletonJson { timelines.shrink(); float duration = 0; + Object[] items = timelines.items; for (int i = 0, n = timelines.size; i < n; i++) - duration = Math.max(duration, timelines.get(i).getDuration()); + duration = Math.max(duration, ((Timeline)items[i]).getDuration()); skeletonData.animations.add(new Animation(name, timelines, duration)); } diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonRenderer.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonRenderer.java index 1e8e251f1..862ddd20c 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonRenderer.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/SkeletonRenderer.java @@ -34,7 +34,6 @@ import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; import com.badlogic.gdx.math.Vector2; -import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.FloatArray; import com.badlogic.gdx.utils.Null; import com.badlogic.gdx.utils.NumberUtils; @@ -89,9 +88,9 @@ public class SkeletonRenderer { float[] vertices = this.vertices.items; Color skeletonColor = skeleton.color; float r = skeletonColor.r, g = skeletonColor.g, b = skeletonColor.b, a = skeletonColor.a; - Array drawOrder = skeleton.drawOrder; - for (int i = 0, n = drawOrder.size; i < n; i++) { - Slot slot = drawOrder.get(i); + Object[] drawOrder = skeleton.drawOrder.items; + for (int i = 0, n = skeleton.drawOrder.size; i < n; i++) { + Slot slot = (Slot)drawOrder[i]; if (!slot.bone.active) continue; Attachment attachment = slot.attachment; if (attachment instanceof RegionAttachment) { @@ -167,9 +166,9 @@ public class SkeletonRenderer { short[] triangles = null; Color color = null, skeletonColor = skeleton.color; float r = skeletonColor.r, g = skeletonColor.g, b = skeletonColor.b, a = skeletonColor.a; - Array drawOrder = skeleton.drawOrder; - for (int i = 0, n = drawOrder.size; i < n; i++) { - Slot slot = drawOrder.get(i); + Object[] drawOrder = skeleton.drawOrder.items; + for (int i = 0, n = skeleton.drawOrder.size; i < n; i++) { + Slot slot = (Slot)drawOrder[i]; if (!slot.bone.active) continue; Texture texture = null; int vertexSize = clipper.isClipping() ? 2 : 5; @@ -290,9 +289,9 @@ public class SkeletonRenderer { short[] triangles = null; Color color = null, skeletonColor = skeleton.color; float r = skeletonColor.r, g = skeletonColor.g, b = skeletonColor.b, a = skeletonColor.a; - Array drawOrder = skeleton.drawOrder; - for (int i = 0, n = drawOrder.size; i < n; i++) { - Slot slot = drawOrder.get(i); + Object[] drawOrder = skeleton.drawOrder.items; + for (int i = 0, n = skeleton.drawOrder.size; i < n; i++) { + Slot slot = (Slot)drawOrder[i]; if (!slot.bone.active) continue; Texture texture = null; int vertexSize = clipper.isClipping() ? 2 : 6; diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skin.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skin.java index 0d294841a..d52feaa16 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skin.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/Skin.java @@ -146,9 +146,10 @@ public class Skin { /** Attach each attachment in this skin if the corresponding attachment in the old skin is currently attached. */ void attachAll (Skeleton skeleton, Skin oldSkin) { + Object[] slots = skeleton.slots.items; for (SkinEntry entry : oldSkin.attachments.orderedItems()) { int slotIndex = entry.slotIndex; - Slot slot = skeleton.slots.get(slotIndex); + Slot slot = (Slot)slots[slotIndex]; if (slot.attachment == entry.attachment) { Attachment attachment = getAttachment(slotIndex, entry.name); if (attachment != null) slot.setAttachment(attachment); diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/TransformConstraint.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/TransformConstraint.java index aef88fed6..968304d36 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/TransformConstraint.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/TransformConstraint.java @@ -97,14 +97,14 @@ public class TransformConstraint implements Updatable { private void applyAbsoluteWorld () { float rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; + if (rotateMix == 0 && translateMix == 0 && scaleMix == 0 && shearMix == 0) return; Bone target = this.target; float ta = target.a, tb = target.b, tc = target.c, td = target.d; float degRadReflect = ta * td - tb * tc > 0 ? degRad : -degRad; float offsetRotation = data.offsetRotation * degRadReflect, offsetShearY = data.offsetShearY * degRadReflect; - Array bones = this.bones; - for (int i = 0, n = bones.size; i < n; i++) { - Bone bone = bones.get(i); - boolean modified = false; + Object[] bones = this.bones.items; + for (int i = 0, n = this.bones.size; i < n; i++) { + Bone bone = (Bone)bones[i]; if (rotateMix != 0) { float a = bone.a, b = bone.b, c = bone.c, d = bone.d; @@ -118,7 +118,6 @@ public class TransformConstraint implements Updatable { bone.b = cos * b - sin * d; bone.c = sin * a + cos * c; bone.d = sin * b + cos * d; - modified = true; } if (translateMix != 0) { @@ -126,7 +125,6 @@ public class TransformConstraint implements Updatable { target.localToWorld(temp.set(data.offsetX, data.offsetY)); bone.worldX += (temp.x - bone.worldX) * translateMix; bone.worldY += (temp.y - bone.worldY) * translateMix; - modified = true; } if (scaleMix > 0) { @@ -138,7 +136,6 @@ public class TransformConstraint implements Updatable { if (s != 0) s = (s + ((float)Math.sqrt(tb * tb + td * td) - s + data.offsetScaleY) * scaleMix) / s; bone.b *= s; bone.d *= s; - modified = true; } if (shearMix > 0) { @@ -152,23 +149,22 @@ public class TransformConstraint implements Updatable { float s = (float)Math.sqrt(b * b + d * d); bone.b = cos(r) * s; bone.d = sin(r) * s; - modified = true; } - if (modified) bone.appliedValid = false; + bone.appliedValid = false; } } private void applyRelativeWorld () { float rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; + if (rotateMix == 0 && translateMix == 0 && scaleMix == 0 && shearMix == 0) return; Bone target = this.target; float ta = target.a, tb = target.b, tc = target.c, td = target.d; float degRadReflect = ta * td - tb * tc > 0 ? degRad : -degRad; float offsetRotation = data.offsetRotation * degRadReflect, offsetShearY = data.offsetShearY * degRadReflect; - Array bones = this.bones; - for (int i = 0, n = bones.size; i < n; i++) { - Bone bone = bones.get(i); - boolean modified = false; + Object[] bones = this.bones.items; + for (int i = 0, n = this.bones.size; i < n; i++) { + Bone bone = (Bone)bones[i]; if (rotateMix != 0) { float a = bone.a, b = bone.b, c = bone.c, d = bone.d; @@ -182,7 +178,6 @@ public class TransformConstraint implements Updatable { bone.b = cos * b - sin * d; bone.c = sin * a + cos * c; bone.d = sin * b + cos * d; - modified = true; } if (translateMix != 0) { @@ -190,7 +185,6 @@ public class TransformConstraint implements Updatable { target.localToWorld(temp.set(data.offsetX, data.offsetY)); bone.worldX += temp.x * translateMix; bone.worldY += temp.y * translateMix; - modified = true; } if (scaleMix > 0) { @@ -200,7 +194,6 @@ public class TransformConstraint implements Updatable { s = ((float)Math.sqrt(tb * tb + td * td) - 1 + data.offsetScaleY) * scaleMix + 1; bone.b *= s; bone.d *= s; - modified = true; } if (shearMix > 0) { @@ -213,10 +206,9 @@ public class TransformConstraint implements Updatable { float s = (float)Math.sqrt(b * b + d * d); bone.b = cos(r) * s; bone.d = sin(r) * s; - modified = true; } - if (modified) bone.appliedValid = false; + bone.appliedValid = false; } } @@ -224,9 +216,9 @@ public class TransformConstraint implements Updatable { float rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; Bone target = this.target; if (!target.appliedValid) target.updateAppliedTransform(); - Array bones = this.bones; - for (int i = 0, n = bones.size; i < n; i++) { - Bone bone = bones.get(i); + Object[] bones = this.bones.items; + for (int i = 0, n = this.bones.size; i < n; i++) { + Bone bone = (Bone)bones[i]; if (!bone.appliedValid) bone.updateAppliedTransform(); float rotation = bone.arotation; @@ -263,9 +255,9 @@ public class TransformConstraint implements Updatable { float rotateMix = this.rotateMix, translateMix = this.translateMix, scaleMix = this.scaleMix, shearMix = this.shearMix; Bone target = this.target; if (!target.appliedValid) target.updateAppliedTransform(); - Array bones = this.bones; - for (int i = 0, n = bones.size; i < n; i++) { - Bone bone = bones.get(i); + Object[] bones = this.bones.items; + for (int i = 0, n = this.bones.size; i < n; i++) { + Bone bone = (Bone)bones[i]; if (!bone.appliedValid) bone.updateAppliedTransform(); float rotation = bone.arotation; diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/utils/SkeletonActorPool.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/utils/SkeletonActorPool.java index c0ac60fae..d4506eee4 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/utils/SkeletonActorPool.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/utils/SkeletonActorPool.java @@ -91,10 +91,10 @@ public class SkeletonActorPool extends Pool { /** Each obtained skeleton actor that is no longer playing an animation is removed from the stage and returned to the pool. */ public void freeComplete () { - Array obtained = this.obtained; + Object[] obtained = this.obtained.items; outer: - for (int i = obtained.size - 1; i >= 0; i--) { - SkeletonActor actor = obtained.get(i); + for (int i = this.obtained.size - 1; i >= 0; i--) { + SkeletonActor actor = (SkeletonActor)obtained[i]; Array tracks = actor.state.getTracks(); for (int ii = 0, nn = tracks.size; ii < nn; ii++) if (tracks.get(ii) != null) continue outer; diff --git a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/utils/Triangulator.java b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/utils/Triangulator.java index 1bebabc67..d1d52bcfd 100644 --- a/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/utils/Triangulator.java +++ b/spine-libgdx/spine-libgdx/src/com/esotericsoftware/spine/utils/Triangulator.java @@ -181,7 +181,7 @@ class Triangulator { convexPolygonsIndices.add(polygonIndices); } else { polygonPool.free(polygon); - polygonIndicesPool.free(polygonIndices); + polygonIndicesPool.free(polygonIndices); } polygon = polygonPool.obtain(); polygon.clear(); @@ -207,13 +207,14 @@ class Triangulator { } // Go through the list of polygons and try to merge the remaining triangles with the found triangle fans. + Object[] convexPolygonsIndicesItems = convexPolygonsIndices.items, convexPolygonsItems = convexPolygons.items; for (int i = 0, n = convexPolygons.size; i < n; i++) { - polygonIndices = convexPolygonsIndices.get(i); + polygonIndices = (ShortArray)convexPolygonsIndicesItems[i]; if (polygonIndices.size == 0) continue; - int firstIndex = polygonIndices.get(0); + int firstIndex = polygonIndices.first(); int lastIndex = polygonIndices.get(polygonIndices.size - 1); - polygon = convexPolygons.get(i); + polygon = (FloatArray)convexPolygonsItems[i]; int o = polygon.size - 4; float[] p = polygon.items; float prevPrevX = p[o], prevPrevY = p[o + 1]; @@ -224,13 +225,13 @@ class Triangulator { for (int ii = 0; ii < n; ii++) { if (ii == i) continue; - ShortArray otherIndices = convexPolygonsIndices.get(ii); + ShortArray otherIndices = (ShortArray)convexPolygonsIndicesItems[ii]; if (otherIndices.size != 3) continue; - int otherFirstIndex = otherIndices.get(0); + int otherFirstIndex = otherIndices.first(); int otherSecondIndex = otherIndices.get(1); int otherLastIndex = otherIndices.get(2); - FloatArray otherPoly = convexPolygons.get(ii); + FloatArray otherPoly = (FloatArray)convexPolygonsItems[ii]; float x3 = otherPoly.get(otherPoly.size - 2), y3 = otherPoly.get(otherPoly.size - 1); if (otherFirstIndex != firstIndex || otherSecondIndex != lastIndex) continue; @@ -253,11 +254,11 @@ class Triangulator { // Remove empty polygons that resulted from the merge step above. for (int i = convexPolygons.size - 1; i >= 0; i--) { - polygon = convexPolygons.get(i); + polygon = (FloatArray)convexPolygonsItems[i]; if (polygon.size == 0) { convexPolygons.removeIndex(i); polygonPool.free(polygon); - polygonIndices = convexPolygonsIndices.removeIndex(i); + polygonIndices = convexPolygonsIndices.removeIndex(i); polygonIndicesPool.free(polygonIndices); } }