Sequence attachment fixes.

This commit is contained in:
Nathan Sweet 2021-10-04 20:48:58 -10:00
parent f7ae127115
commit d798334a5e
2 changed files with 58 additions and 60 deletions

View File

@ -878,22 +878,19 @@ public class SkeletonJson extends SkeletonLoader {
} }
// Attachment timelines. // Attachment timelines.
for (JsonValue deformMap = map.getChild("attachments"); deformMap != null; deformMap = deformMap.next) { for (JsonValue attachmentsMap = map.getChild("attachments"); attachmentsMap != null; attachmentsMap = attachmentsMap.next) {
Skin skin = skeletonData.findSkin(deformMap.name); Skin skin = skeletonData.findSkin(attachmentsMap.name);
if (skin == null) throw new SerializationException("Skin not found: " + deformMap.name); if (skin == null) throw new SerializationException("Skin not found: " + attachmentsMap.name);
for (JsonValue slotMap = deformMap.child; slotMap != null; slotMap = slotMap.next) { for (JsonValue slotMap = attachmentsMap.child; slotMap != null; slotMap = slotMap.next) {
SlotData slot = skeletonData.findSlot(slotMap.name); SlotData slot = skeletonData.findSlot(slotMap.name);
if (slot == null) throw new SerializationException("Slot not found: " + slotMap.name); if (slot == null) throw new SerializationException("Slot not found: " + slotMap.name);
for (JsonValue timelineMap = slotMap.child; timelineMap != null; timelineMap = timelineMap.next) { for (JsonValue attachmentMap = slotMap.child; attachmentMap != null; attachmentMap = attachmentMap.next) {
Attachment attachment = skin.getAttachment(slot.index, attachmentMap.name);
if (attachment == null) throw new SerializationException("Timeline attachment not found: " + attachmentMap.name);
for (JsonValue timelineMap = attachmentMap.child; timelineMap != null; timelineMap = timelineMap.next) {
JsonValue keyMap = timelineMap.child; JsonValue keyMap = timelineMap.child;
if (keyMap == null) continue; int frames = timelineMap.size;
String timelineName = timelineMap.name;
Attachment attachment = skin.getAttachment(slot.index, timelineMap.name);
if (attachment == null) throw new SerializationException("Timeline attachment not found: " + timelineMap.name);
int frames = keyMap.size;
String timelineName = keyMap.name;
keyMap = keyMap.child;
if (timelineName.equals("deform")) { if (timelineName.equals("deform")) {
VertexAttachment vertexAttachment = (VertexAttachment)attachment; VertexAttachment vertexAttachment = (VertexAttachment)attachment;
boolean weighted = vertexAttachment.getBones() != null; boolean weighted = vertexAttachment.getBones() != null;
@ -939,15 +936,16 @@ public class SkeletonJson extends SkeletonLoader {
float lastDelay = 0; float lastDelay = 0;
for (int frame = 0; keyMap != null; keyMap = keyMap.next, frame++) { for (int frame = 0; keyMap != null; keyMap = keyMap.next, frame++) {
float delay = keyMap.getFloat("delay", lastDelay); float delay = keyMap.getFloat("delay", lastDelay);
timeline.setFrame(frame, keyMap.getFloat("time", 0), SequenceMode.valueOf(keyMap.getString("mode", "stop")), timeline.setFrame(frame, keyMap.getFloat("time", 0),
keyMap.getInt("index", 0), delay); SequenceMode.valueOf(keyMap.getString("mode", "stop")), keyMap.getInt("index", 0), delay);
delay = lastDelay; lastDelay = delay;
} }
timelines.add(timeline); timelines.add(timeline);
} }
} }
} }
} }
}
// Draw order timeline. // Draw order timeline.
JsonValue drawOrdersMap = map.get("drawOrder"); JsonValue drawOrdersMap = map.get("drawOrder");

View File

@ -286,7 +286,7 @@ public class MeshAttachment extends VertexAttachment implements HasTextureRegion
mesh.path = path; mesh.path = path;
mesh.color.set(color); mesh.color.set(color);
mesh.setParentMesh(parentMesh != null ? parentMesh : this); mesh.setParentMesh(parentMesh != null ? parentMesh : this);
mesh.updateRegion(); if (mesh.getRegion() != null) mesh.updateRegion();
return mesh; return mesh;
} }