[libgdx] Removed deferred attachment lookup.

This commit is contained in:
NathanSweet 2016-06-28 17:28:16 +02:00
parent 206e7f983c
commit 5951e9f6b2
9 changed files with 14 additions and 18 deletions

View File

@ -540,7 +540,8 @@ public class Animation {
frameIndex = binarySearch(frames, time, 1) - 1;
String attachmentName = attachmentNames[frameIndex];
skeleton.slots.get(slotIndex).attachmentName = attachmentName;
Slot slot = skeleton.slots.get(slotIndex);
slot.setAttachment(skeleton.getAttachment(slot.data.index, attachmentName));
}
}
@ -695,7 +696,7 @@ public class Animation {
public void apply (Skeleton skeleton, float lastTime, float time, Array<Event> firedEvents, float alpha) {
Slot slot = skeleton.slots.get(slotIndex);
Attachment slotAttachment = slot.getAttachment();
Attachment slotAttachment = slot.attachment;
if (!(slotAttachment instanceof VertexAttachment) || !((VertexAttachment)slotAttachment).applyDeform(attachment)) return;
float[] frames = this.frames;

View File

@ -58,7 +58,7 @@ public class PathConstraint implements Updatable {
@SuppressWarnings("null")
public void update () {
Attachment attachment = target.getAttachment();
Attachment attachment = target.attachment;
if (!(attachment instanceof PathAttachment)) return;
float rotateMix = this.rotateMix, translateMix = this.translateMix;

View File

@ -203,7 +203,7 @@ public class Skeleton {
for (int ii = 0, nn = data.skins.size; ii < nn; ii++)
sortPathConstraintAttachment(data.skins.get(ii), slotIndex, slotBone);
Attachment attachment = slot.getAttachment();
Attachment attachment = slot.attachment;
if (attachment instanceof PathAttachment) sortPathConstraintAttachment(attachment, slotBone);
Array<Bone> constrained = constraint.bones;
@ -530,7 +530,7 @@ public class Skeleton {
for (int i = 0, n = drawOrder.size; i < n; i++) {
Slot slot = drawOrder.get(i);
float[] vertices = null;
Attachment attachment = slot.getAttachment();
Attachment attachment = slot.attachment;
if (attachment instanceof RegionAttachment)
vertices = ((RegionAttachment)attachment).updateWorldVertices(slot, false);
else if (attachment instanceof MeshAttachment) //

View File

@ -61,7 +61,7 @@ public class SkeletonBounds {
for (int i = 0; i < slotCount; i++) {
Slot slot = slots.get(i);
Attachment attachment = slot.getAttachment();
Attachment attachment = slot.attachment;
if (attachment instanceof BoundingBoxAttachment) {
BoundingBoxAttachment boundingBox = (BoundingBoxAttachment)attachment;
boundingBoxes.add(boundingBox);

View File

@ -52,7 +52,7 @@ public class SkeletonMeshRenderer extends SkeletonRenderer<PolygonSpriteBatch> {
Array<Slot> drawOrder = skeleton.drawOrder;
for (int i = 0, n = drawOrder.size; i < n; i++) {
Slot slot = drawOrder.get(i);
Attachment attachment = slot.getAttachment();
Attachment attachment = slot.attachment;
Texture texture = null;
if (attachment instanceof RegionAttachment) {
RegionAttachment region = (RegionAttachment)attachment;

View File

@ -48,7 +48,7 @@ public class SkeletonRenderer<T extends Batch> {
Array<Slot> drawOrder = skeleton.drawOrder;
for (int i = 0, n = drawOrder.size; i < n; i++) {
Slot slot = drawOrder.get(i);
Attachment attachment = slot.getAttachment();
Attachment attachment = slot.attachment;
if (attachment instanceof RegionAttachment) {
RegionAttachment regionAttachment = (RegionAttachment)attachment;
float[] vertices = regionAttachment.updateWorldVertices(slot, premultipliedAlpha);

View File

@ -102,7 +102,7 @@ public class SkeletonRendererDebug {
Array<Slot> slots = skeleton.getSlots();
for (int i = 0, n = slots.size; i < n; i++) {
Slot slot = slots.get(i);
Attachment attachment = slot.getAttachment();
Attachment attachment = slot.attachment;
if (attachment instanceof RegionAttachment) {
RegionAttachment regionAttachment = (RegionAttachment)attachment;
float[] vertices = regionAttachment.updateWorldVertices(slot, false);
@ -118,7 +118,7 @@ public class SkeletonRendererDebug {
Array<Slot> slots = skeleton.getSlots();
for (int i = 0, n = slots.size; i < n; i++) {
Slot slot = slots.get(i);
Attachment attachment = slot.getAttachment();
Attachment attachment = slot.attachment;
if (!(attachment instanceof MeshAttachment)) continue;
MeshAttachment mesh = (MeshAttachment)attachment;
mesh.updateWorldVertices(slot, false);
@ -167,7 +167,7 @@ public class SkeletonRendererDebug {
Array<Slot> slots = skeleton.getSlots();
for (int i = 0, n = slots.size; i < n; i++) {
Slot slot = slots.get(i);
Attachment attachment = slot.getAttachment();
Attachment attachment = slot.attachment;
if (!(attachment instanceof PathAttachment)) continue;
PathAttachment path = (PathAttachment)attachment;
int nn = path.getWorldVerticesLength();

View File

@ -102,7 +102,7 @@ public class Skin {
for (Entry<Key, Attachment> entry : oldSkin.attachments.entries()) {
int slotIndex = entry.key.slotIndex;
Slot slot = skeleton.slots.get(slotIndex);
if (slot.getAttachment() == entry.value) {
if (slot.attachment == entry.value) {
Attachment attachment = getAttachment(slotIndex, entry.key.name);
if (attachment != null) slot.setAttachment(attachment);
}

View File

@ -39,10 +39,9 @@ public class Slot {
final SlotData data;
final Bone bone;
final Color color;
private Attachment attachment;
Attachment attachment;
private float attachmentTime;
private FloatArray attachmentVertices = new FloatArray();
String attachmentName;
public Slot (SlotData data, Bone bone) {
if (data == null) throw new IllegalArgumentException("data cannot be null.");
@ -82,10 +81,6 @@ public class Slot {
/** @return May be null. */
public Attachment getAttachment () {
if (attachmentName != null) {
setAttachment(bone.skeleton.getAttachment(data.index, attachmentName));
attachmentName = null;
}
return attachment;
}