mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 06:29:02 +08:00
Fixed attachment keys on different tracks.
badlogic/spine-internal#49 (cherry picked from commit 6cccbf61f3bd9f125958fac6eb120b839ae82738)
This commit is contained in:
parent
ac00899175
commit
206e7f983c
@ -531,18 +531,16 @@ public class Animation {
|
||||
|
||||
public void apply (Skeleton skeleton, float lastTime, float time, Array<Event> events, float alpha) {
|
||||
float[] frames = this.frames;
|
||||
if (time < frames[0]) {
|
||||
if (lastTime > time) apply(skeleton, lastTime, Integer.MAX_VALUE, null, 0);
|
||||
return;
|
||||
} else if (lastTime > time) //
|
||||
lastTime = -1;
|
||||
if (time < frames[0]) return; // Time is before first frame.
|
||||
|
||||
int frame = (time >= frames[frames.length - 1] ? frames.length : binarySearch(frames, time)) - 1;
|
||||
if (frames[frame] < lastTime) return;
|
||||
int frameIndex;
|
||||
if (time >= frames[frames.length - 1]) // Time is after last frame.
|
||||
frameIndex = frames.length - 1;
|
||||
else
|
||||
frameIndex = binarySearch(frames, time, 1) - 1;
|
||||
|
||||
String attachmentName = attachmentNames[frame];
|
||||
skeleton.slots.get(slotIndex)
|
||||
.setAttachment(attachmentName == null ? null : skeleton.getAttachment(slotIndex, attachmentName));
|
||||
String attachmentName = attachmentNames[frameIndex];
|
||||
skeleton.slots.get(slotIndex).attachmentName = attachmentName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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.attachment;
|
||||
Attachment attachment = slot.getAttachment();
|
||||
if (attachment instanceof RegionAttachment)
|
||||
vertices = ((RegionAttachment)attachment).updateWorldVertices(slot, false);
|
||||
else if (attachment instanceof MeshAttachment) //
|
||||
|
||||
@ -61,7 +61,7 @@ public class SkeletonBounds {
|
||||
|
||||
for (int i = 0; i < slotCount; i++) {
|
||||
Slot slot = slots.get(i);
|
||||
Attachment attachment = slot.attachment;
|
||||
Attachment attachment = slot.getAttachment();
|
||||
if (attachment instanceof BoundingBoxAttachment) {
|
||||
BoundingBoxAttachment boundingBox = (BoundingBoxAttachment)attachment;
|
||||
boundingBoxes.add(boundingBox);
|
||||
|
||||
@ -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.attachment;
|
||||
Attachment attachment = slot.getAttachment();
|
||||
Texture texture = null;
|
||||
if (attachment instanceof RegionAttachment) {
|
||||
RegionAttachment region = (RegionAttachment)attachment;
|
||||
|
||||
@ -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.attachment;
|
||||
Attachment attachment = slot.getAttachment();
|
||||
if (attachment instanceof RegionAttachment) {
|
||||
RegionAttachment regionAttachment = (RegionAttachment)attachment;
|
||||
float[] vertices = regionAttachment.updateWorldVertices(slot, premultipliedAlpha);
|
||||
|
||||
@ -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.attachment;
|
||||
Attachment attachment = slot.getAttachment();
|
||||
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.attachment;
|
||||
Attachment attachment = slot.getAttachment();
|
||||
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.attachment;
|
||||
Attachment attachment = slot.getAttachment();
|
||||
if (!(attachment instanceof PathAttachment)) continue;
|
||||
PathAttachment path = (PathAttachment)attachment;
|
||||
int nn = path.getWorldVerticesLength();
|
||||
|
||||
@ -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.attachment == entry.value) {
|
||||
if (slot.getAttachment() == entry.value) {
|
||||
Attachment attachment = getAttachment(slotIndex, entry.key.name);
|
||||
if (attachment != null) slot.setAttachment(attachment);
|
||||
}
|
||||
|
||||
@ -31,18 +31,18 @@
|
||||
|
||||
package com.esotericsoftware.spine;
|
||||
|
||||
import com.esotericsoftware.spine.attachments.Attachment;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.utils.FloatArray;
|
||||
import com.esotericsoftware.spine.attachments.Attachment;
|
||||
|
||||
public class Slot {
|
||||
final SlotData data;
|
||||
final Bone bone;
|
||||
final Color color;
|
||||
Attachment attachment;
|
||||
private 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,9 +82,19 @@ public class Slot {
|
||||
|
||||
/** @return May be null. */
|
||||
public Attachment getAttachment () {
|
||||
if (attachmentName != null) {
|
||||
setAttachment(bone.skeleton.getAttachment(data.index, attachmentName));
|
||||
attachmentName = null;
|
||||
}
|
||||
return attachment;
|
||||
}
|
||||
|
||||
/** Sets the name of the attachment which will be used to find the attachment in the skin the next time
|
||||
* {@link #getAttachment()} is called. */
|
||||
public void setAttachmentName (String attachmentName) {
|
||||
this.attachmentName = attachmentName;
|
||||
}
|
||||
|
||||
/** Sets the attachment and if it changed, resets {@link #getAttachmentTime()} and clears {@link #getAttachmentVertices()}.
|
||||
* @param attachment May be null. */
|
||||
public void setAttachment (Attachment attachment) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user