mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[libgdx] Removed deferred attachment lookup.
This commit is contained in:
parent
206e7f983c
commit
5951e9f6b2
@ -540,7 +540,8 @@ public class Animation {
|
|||||||
frameIndex = binarySearch(frames, time, 1) - 1;
|
frameIndex = binarySearch(frames, time, 1) - 1;
|
||||||
|
|
||||||
String attachmentName = attachmentNames[frameIndex];
|
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) {
|
public void apply (Skeleton skeleton, float lastTime, float time, Array<Event> firedEvents, float alpha) {
|
||||||
Slot slot = skeleton.slots.get(slotIndex);
|
Slot slot = skeleton.slots.get(slotIndex);
|
||||||
Attachment slotAttachment = slot.getAttachment();
|
Attachment slotAttachment = slot.attachment;
|
||||||
if (!(slotAttachment instanceof VertexAttachment) || !((VertexAttachment)slotAttachment).applyDeform(attachment)) return;
|
if (!(slotAttachment instanceof VertexAttachment) || !((VertexAttachment)slotAttachment).applyDeform(attachment)) return;
|
||||||
|
|
||||||
float[] frames = this.frames;
|
float[] frames = this.frames;
|
||||||
|
|||||||
@ -58,7 +58,7 @@ public class PathConstraint implements Updatable {
|
|||||||
|
|
||||||
@SuppressWarnings("null")
|
@SuppressWarnings("null")
|
||||||
public void update () {
|
public void update () {
|
||||||
Attachment attachment = target.getAttachment();
|
Attachment attachment = target.attachment;
|
||||||
if (!(attachment instanceof PathAttachment)) return;
|
if (!(attachment instanceof PathAttachment)) return;
|
||||||
|
|
||||||
float rotateMix = this.rotateMix, translateMix = this.translateMix;
|
float rotateMix = this.rotateMix, translateMix = this.translateMix;
|
||||||
|
|||||||
@ -203,7 +203,7 @@ public class Skeleton {
|
|||||||
for (int ii = 0, nn = data.skins.size; ii < nn; ii++)
|
for (int ii = 0, nn = data.skins.size; ii < nn; ii++)
|
||||||
sortPathConstraintAttachment(data.skins.get(ii), slotIndex, slotBone);
|
sortPathConstraintAttachment(data.skins.get(ii), slotIndex, slotBone);
|
||||||
|
|
||||||
Attachment attachment = slot.getAttachment();
|
Attachment attachment = slot.attachment;
|
||||||
if (attachment instanceof PathAttachment) sortPathConstraintAttachment(attachment, slotBone);
|
if (attachment instanceof PathAttachment) sortPathConstraintAttachment(attachment, slotBone);
|
||||||
|
|
||||||
Array<Bone> constrained = constraint.bones;
|
Array<Bone> constrained = constraint.bones;
|
||||||
@ -530,7 +530,7 @@ public class Skeleton {
|
|||||||
for (int i = 0, n = drawOrder.size; i < n; i++) {
|
for (int i = 0, n = drawOrder.size; i < n; i++) {
|
||||||
Slot slot = drawOrder.get(i);
|
Slot slot = drawOrder.get(i);
|
||||||
float[] vertices = null;
|
float[] vertices = null;
|
||||||
Attachment attachment = slot.getAttachment();
|
Attachment attachment = slot.attachment;
|
||||||
if (attachment instanceof RegionAttachment)
|
if (attachment instanceof RegionAttachment)
|
||||||
vertices = ((RegionAttachment)attachment).updateWorldVertices(slot, false);
|
vertices = ((RegionAttachment)attachment).updateWorldVertices(slot, false);
|
||||||
else if (attachment instanceof MeshAttachment) //
|
else if (attachment instanceof MeshAttachment) //
|
||||||
|
|||||||
@ -61,7 +61,7 @@ public class SkeletonBounds {
|
|||||||
|
|
||||||
for (int i = 0; i < slotCount; i++) {
|
for (int i = 0; i < slotCount; i++) {
|
||||||
Slot slot = slots.get(i);
|
Slot slot = slots.get(i);
|
||||||
Attachment attachment = slot.getAttachment();
|
Attachment attachment = slot.attachment;
|
||||||
if (attachment instanceof BoundingBoxAttachment) {
|
if (attachment instanceof BoundingBoxAttachment) {
|
||||||
BoundingBoxAttachment boundingBox = (BoundingBoxAttachment)attachment;
|
BoundingBoxAttachment boundingBox = (BoundingBoxAttachment)attachment;
|
||||||
boundingBoxes.add(boundingBox);
|
boundingBoxes.add(boundingBox);
|
||||||
|
|||||||
@ -52,7 +52,7 @@ public class SkeletonMeshRenderer extends SkeletonRenderer<PolygonSpriteBatch> {
|
|||||||
Array<Slot> drawOrder = skeleton.drawOrder;
|
Array<Slot> drawOrder = skeleton.drawOrder;
|
||||||
for (int i = 0, n = drawOrder.size; i < n; i++) {
|
for (int i = 0, n = drawOrder.size; i < n; i++) {
|
||||||
Slot slot = drawOrder.get(i);
|
Slot slot = drawOrder.get(i);
|
||||||
Attachment attachment = slot.getAttachment();
|
Attachment attachment = slot.attachment;
|
||||||
Texture texture = null;
|
Texture texture = null;
|
||||||
if (attachment instanceof RegionAttachment) {
|
if (attachment instanceof RegionAttachment) {
|
||||||
RegionAttachment region = (RegionAttachment)attachment;
|
RegionAttachment region = (RegionAttachment)attachment;
|
||||||
|
|||||||
@ -48,7 +48,7 @@ public class SkeletonRenderer<T extends Batch> {
|
|||||||
Array<Slot> drawOrder = skeleton.drawOrder;
|
Array<Slot> drawOrder = skeleton.drawOrder;
|
||||||
for (int i = 0, n = drawOrder.size; i < n; i++) {
|
for (int i = 0, n = drawOrder.size; i < n; i++) {
|
||||||
Slot slot = drawOrder.get(i);
|
Slot slot = drawOrder.get(i);
|
||||||
Attachment attachment = slot.getAttachment();
|
Attachment attachment = slot.attachment;
|
||||||
if (attachment instanceof RegionAttachment) {
|
if (attachment instanceof RegionAttachment) {
|
||||||
RegionAttachment regionAttachment = (RegionAttachment)attachment;
|
RegionAttachment regionAttachment = (RegionAttachment)attachment;
|
||||||
float[] vertices = regionAttachment.updateWorldVertices(slot, premultipliedAlpha);
|
float[] vertices = regionAttachment.updateWorldVertices(slot, premultipliedAlpha);
|
||||||
|
|||||||
@ -102,7 +102,7 @@ public class SkeletonRendererDebug {
|
|||||||
Array<Slot> slots = skeleton.getSlots();
|
Array<Slot> slots = skeleton.getSlots();
|
||||||
for (int i = 0, n = slots.size; i < n; i++) {
|
for (int i = 0, n = slots.size; i < n; i++) {
|
||||||
Slot slot = slots.get(i);
|
Slot slot = slots.get(i);
|
||||||
Attachment attachment = slot.getAttachment();
|
Attachment attachment = slot.attachment;
|
||||||
if (attachment instanceof RegionAttachment) {
|
if (attachment instanceof RegionAttachment) {
|
||||||
RegionAttachment regionAttachment = (RegionAttachment)attachment;
|
RegionAttachment regionAttachment = (RegionAttachment)attachment;
|
||||||
float[] vertices = regionAttachment.updateWorldVertices(slot, false);
|
float[] vertices = regionAttachment.updateWorldVertices(slot, false);
|
||||||
@ -118,7 +118,7 @@ public class SkeletonRendererDebug {
|
|||||||
Array<Slot> slots = skeleton.getSlots();
|
Array<Slot> slots = skeleton.getSlots();
|
||||||
for (int i = 0, n = slots.size; i < n; i++) {
|
for (int i = 0, n = slots.size; i < n; i++) {
|
||||||
Slot slot = slots.get(i);
|
Slot slot = slots.get(i);
|
||||||
Attachment attachment = slot.getAttachment();
|
Attachment attachment = slot.attachment;
|
||||||
if (!(attachment instanceof MeshAttachment)) continue;
|
if (!(attachment instanceof MeshAttachment)) continue;
|
||||||
MeshAttachment mesh = (MeshAttachment)attachment;
|
MeshAttachment mesh = (MeshAttachment)attachment;
|
||||||
mesh.updateWorldVertices(slot, false);
|
mesh.updateWorldVertices(slot, false);
|
||||||
@ -167,7 +167,7 @@ public class SkeletonRendererDebug {
|
|||||||
Array<Slot> slots = skeleton.getSlots();
|
Array<Slot> slots = skeleton.getSlots();
|
||||||
for (int i = 0, n = slots.size; i < n; i++) {
|
for (int i = 0, n = slots.size; i < n; i++) {
|
||||||
Slot slot = slots.get(i);
|
Slot slot = slots.get(i);
|
||||||
Attachment attachment = slot.getAttachment();
|
Attachment attachment = slot.attachment;
|
||||||
if (!(attachment instanceof PathAttachment)) continue;
|
if (!(attachment instanceof PathAttachment)) continue;
|
||||||
PathAttachment path = (PathAttachment)attachment;
|
PathAttachment path = (PathAttachment)attachment;
|
||||||
int nn = path.getWorldVerticesLength();
|
int nn = path.getWorldVerticesLength();
|
||||||
|
|||||||
@ -102,7 +102,7 @@ public class Skin {
|
|||||||
for (Entry<Key, Attachment> entry : oldSkin.attachments.entries()) {
|
for (Entry<Key, Attachment> entry : oldSkin.attachments.entries()) {
|
||||||
int slotIndex = entry.key.slotIndex;
|
int slotIndex = entry.key.slotIndex;
|
||||||
Slot slot = skeleton.slots.get(slotIndex);
|
Slot slot = skeleton.slots.get(slotIndex);
|
||||||
if (slot.getAttachment() == entry.value) {
|
if (slot.attachment == entry.value) {
|
||||||
Attachment attachment = getAttachment(slotIndex, entry.key.name);
|
Attachment attachment = getAttachment(slotIndex, entry.key.name);
|
||||||
if (attachment != null) slot.setAttachment(attachment);
|
if (attachment != null) slot.setAttachment(attachment);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,10 +39,9 @@ public class Slot {
|
|||||||
final SlotData data;
|
final SlotData data;
|
||||||
final Bone bone;
|
final Bone bone;
|
||||||
final Color color;
|
final Color color;
|
||||||
private Attachment attachment;
|
Attachment attachment;
|
||||||
private float attachmentTime;
|
private float attachmentTime;
|
||||||
private FloatArray attachmentVertices = new FloatArray();
|
private FloatArray attachmentVertices = new FloatArray();
|
||||||
String attachmentName;
|
|
||||||
|
|
||||||
public Slot (SlotData data, Bone bone) {
|
public Slot (SlotData data, Bone bone) {
|
||||||
if (data == null) throw new IllegalArgumentException("data cannot be null.");
|
if (data == null) throw new IllegalArgumentException("data cannot be null.");
|
||||||
@ -82,10 +81,6 @@ public class Slot {
|
|||||||
|
|
||||||
/** @return May be null. */
|
/** @return May be null. */
|
||||||
public Attachment getAttachment () {
|
public Attachment getAttachment () {
|
||||||
if (attachmentName != null) {
|
|
||||||
setAttachment(bone.skeleton.getAttachment(data.index, attachmentName));
|
|
||||||
attachmentName = null;
|
|
||||||
}
|
|
||||||
return attachment;
|
return attachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user