|
@@ -241,12 +241,12 @@ public class SkeletonJson {
|
|
|
for (JsonValue skinMap = root.getChild("skins"); skinMap != null; skinMap = skinMap.next) {
|
|
|
Skin skin = new Skin(skinMap.name);
|
|
|
for (JsonValue slotEntry = skinMap.child; slotEntry != null; slotEntry = slotEntry.next) {
|
|
|
- int slotIndex = skeletonData.findSlotIndex(slotEntry.name);
|
|
|
- if (slotIndex == -1) throw new SerializationException("Slot not found: " + slotEntry.name);
|
|
|
+ SlotData slot = skeletonData.findSlot(slotEntry.name);
|
|
|
+ if (slot == null) throw new SerializationException("Slot not found: " + slotEntry.name);
|
|
|
for (JsonValue entry = slotEntry.child; entry != null; entry = entry.next) {
|
|
|
try {
|
|
|
- Attachment attachment = readAttachment(entry, skin, slotIndex, entry.name);
|
|
|
- if (attachment != null) skin.addAttachment(slotIndex, entry.name, attachment);
|
|
|
+ Attachment attachment = readAttachment(entry, skin, slot.index, entry.name);
|
|
|
+ if (attachment != null) skin.addAttachment(slot.index, entry.name, attachment);
|
|
|
} catch (Exception ex) {
|
|
|
throw new SerializationException("Error reading attachment: " + entry.name + ", skin: " + skin, ex);
|
|
|
}
|
|
@@ -417,13 +417,13 @@ public class SkeletonJson {
|
|
|
|
|
|
// Slot timelines.
|
|
|
for (JsonValue slotMap = map.getChild("slots"); slotMap != null; slotMap = slotMap.next) {
|
|
|
- int slotIndex = skeletonData.findSlotIndex(slotMap.name);
|
|
|
- if (slotIndex == -1) throw new SerializationException("Slot not found: " + slotMap.name);
|
|
|
+ SlotData slot = skeletonData.findSlot(slotMap.name);
|
|
|
+ if (slot == null) throw new SerializationException("Slot not found: " + slotMap.name);
|
|
|
for (JsonValue timelineMap = slotMap.child; timelineMap != null; timelineMap = timelineMap.next) {
|
|
|
String timelineName = timelineMap.name;
|
|
|
if (timelineName.equals("color")) {
|
|
|
ColorTimeline timeline = new ColorTimeline(timelineMap.size);
|
|
|
- timeline.slotIndex = slotIndex;
|
|
|
+ timeline.slotIndex = slot.index;
|
|
|
|
|
|
int frameIndex = 0;
|
|
|
for (JsonValue valueMap = timelineMap.child; valueMap != null; valueMap = valueMap.next) {
|
|
@@ -437,7 +437,7 @@ public class SkeletonJson {
|
|
|
|
|
|
} else if (timelineName.equals("attachment")) {
|
|
|
AttachmentTimeline timeline = new AttachmentTimeline(timelineMap.size);
|
|
|
- timeline.slotIndex = slotIndex;
|
|
|
+ timeline.slotIndex = slot.index;
|
|
|
|
|
|
int frameIndex = 0;
|
|
|
for (JsonValue valueMap = timelineMap.child; valueMap != null; valueMap = valueMap.next)
|
|
@@ -451,13 +451,13 @@ public class SkeletonJson {
|
|
|
|
|
|
// Bone timelines.
|
|
|
for (JsonValue boneMap = map.getChild("bones"); boneMap != null; boneMap = boneMap.next) {
|
|
|
- int boneIndex = skeletonData.findBoneIndex(boneMap.name);
|
|
|
- if (boneIndex == -1) throw new SerializationException("Bone not found: " + boneMap.name);
|
|
|
+ BoneData bone = skeletonData.findBone(boneMap.name);
|
|
|
+ if (bone == null) throw new SerializationException("Bone not found: " + boneMap.name);
|
|
|
for (JsonValue timelineMap = boneMap.child; timelineMap != null; timelineMap = timelineMap.next) {
|
|
|
String timelineName = timelineMap.name;
|
|
|
if (timelineName.equals("rotate")) {
|
|
|
RotateTimeline timeline = new RotateTimeline(timelineMap.size);
|
|
|
- timeline.boneIndex = boneIndex;
|
|
|
+ timeline.boneIndex = bone.index;
|
|
|
|
|
|
int frameIndex = 0;
|
|
|
for (JsonValue valueMap = timelineMap.child; valueMap != null; valueMap = valueMap.next) {
|
|
@@ -479,7 +479,7 @@ public class SkeletonJson {
|
|
|
timeline = new TranslateTimeline(timelineMap.size);
|
|
|
timelineScale = scale;
|
|
|
}
|
|
|
- timeline.boneIndex = boneIndex;
|
|
|
+ timeline.boneIndex = bone.index;
|
|
|
|
|
|
int frameIndex = 0;
|
|
|
for (JsonValue valueMap = timelineMap.child; valueMap != null; valueMap = valueMap.next) {
|
|
@@ -531,9 +531,9 @@ public class SkeletonJson {
|
|
|
|
|
|
// Path constraint timelines.
|
|
|
for (JsonValue constraintMap = map.getChild("paths"); constraintMap != null; constraintMap = constraintMap.next) {
|
|
|
- int index = skeletonData.findPathConstraintIndex(constraintMap.name);
|
|
|
- if (index == -1) throw new SerializationException("Path constraint not found: " + constraintMap.name);
|
|
|
- PathConstraintData data = skeletonData.getPathConstraints().get(index);
|
|
|
+ PathConstraintData data = skeletonData.findPathConstraint(constraintMap.name);
|
|
|
+ if (data == null) throw new SerializationException("Path constraint not found: " + constraintMap.name);
|
|
|
+ int index = skeletonData.pathConstraints.indexOf(data, true);
|
|
|
for (JsonValue timelineMap = constraintMap.child; timelineMap != null; timelineMap = timelineMap.next) {
|
|
|
String timelineName = timelineMap.name;
|
|
|
if (timelineName.equals("position") || timelineName.equals("spacing")) {
|
|
@@ -578,17 +578,17 @@ public class SkeletonJson {
|
|
|
Skin skin = skeletonData.findSkin(deformMap.name);
|
|
|
if (skin == null) throw new SerializationException("Skin not found: " + deformMap.name);
|
|
|
for (JsonValue slotMap = deformMap.child; slotMap != null; slotMap = slotMap.next) {
|
|
|
- int slotIndex = skeletonData.findSlotIndex(slotMap.name);
|
|
|
- if (slotIndex == -1) throw new SerializationException("Slot not found: " + slotMap.name);
|
|
|
+ SlotData slot = skeletonData.findSlot(slotMap.name);
|
|
|
+ if (slot == null) throw new SerializationException("Slot not found: " + slotMap.name);
|
|
|
for (JsonValue timelineMap = slotMap.child; timelineMap != null; timelineMap = timelineMap.next) {
|
|
|
- VertexAttachment attachment = (VertexAttachment)skin.getAttachment(slotIndex, timelineMap.name);
|
|
|
+ VertexAttachment attachment = (VertexAttachment)skin.getAttachment(slot.index, timelineMap.name);
|
|
|
if (attachment == null) throw new SerializationException("Deform attachment not found: " + timelineMap.name);
|
|
|
boolean weighted = attachment.getBones() != null;
|
|
|
float[] vertices = attachment.getVertices();
|
|
|
int deformLength = weighted ? vertices.length / 3 * 2 : vertices.length;
|
|
|
|
|
|
DeformTimeline timeline = new DeformTimeline(timelineMap.size);
|
|
|
- timeline.slotIndex = slotIndex;
|
|
|
+ timeline.slotIndex = slot.index;
|
|
|
timeline.attachment = attachment;
|
|
|
|
|
|
int frameIndex = 0;
|
|
@@ -638,10 +638,10 @@ public class SkeletonJson {
|
|
|
int[] unchanged = new int[slotCount - offsets.size];
|
|
|
int originalIndex = 0, unchangedIndex = 0;
|
|
|
for (JsonValue offsetMap = offsets.child; offsetMap != null; offsetMap = offsetMap.next) {
|
|
|
- int slotIndex = skeletonData.findSlotIndex(offsetMap.getString("slot"));
|
|
|
- if (slotIndex == -1) throw new SerializationException("Slot not found: " + offsetMap.getString("slot"));
|
|
|
+ SlotData slot = skeletonData.findSlot(offsetMap.getString("slot"));
|
|
|
+ if (slot == null) throw new SerializationException("Slot not found: " + offsetMap.getString("slot"));
|
|
|
// Collect unchanged items.
|
|
|
- while (originalIndex != slotIndex)
|
|
|
+ while (originalIndex != slot.index)
|
|
|
unchanged[unchangedIndex++] = originalIndex++;
|
|
|
// Set changed items.
|
|
|
drawOrder[originalIndex + offsetMap.getInt("offset")] = originalIndex++;
|