mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
Fixed clipping end slot.
This commit is contained in:
parent
68d0db8f35
commit
f35bbc33f5
@ -274,7 +274,7 @@ public class SkeletonBinary {
|
||||
}
|
||||
|
||||
// Default skin.
|
||||
Skin defaultSkin = readSkin(input, "default", nonessential);
|
||||
Skin defaultSkin = readSkin(input, skeletonData, "default", nonessential);
|
||||
if (defaultSkin != null) {
|
||||
skeletonData.defaultSkin = defaultSkin;
|
||||
skeletonData.skins.add(defaultSkin);
|
||||
@ -282,7 +282,7 @@ public class SkeletonBinary {
|
||||
|
||||
// Skins.
|
||||
for (int i = 0, n = input.readInt(true); i < n; i++)
|
||||
skeletonData.skins.add(readSkin(input, input.readString(), nonessential));
|
||||
skeletonData.skins.add(readSkin(input, skeletonData, input.readString(), nonessential));
|
||||
|
||||
// Linked meshes.
|
||||
for (int i = 0, n = linkedMeshes.size; i < n; i++) {
|
||||
@ -307,7 +307,7 @@ public class SkeletonBinary {
|
||||
|
||||
// Animations.
|
||||
for (int i = 0, n = input.readInt(true); i < n; i++)
|
||||
readAnimation(input.readString(), input, skeletonData);
|
||||
readAnimation(input, input.readString(), skeletonData);
|
||||
|
||||
} catch (IOException ex) {
|
||||
throw new SerializationException("Error reading skeleton file.", ex);
|
||||
@ -328,7 +328,7 @@ public class SkeletonBinary {
|
||||
}
|
||||
|
||||
/** @return May be null. */
|
||||
private Skin readSkin (DataInput input, String skinName, boolean nonessential) throws IOException {
|
||||
private Skin readSkin (DataInput input, SkeletonData skeletonData, String skinName, boolean nonessential) throws IOException {
|
||||
int slotCount = input.readInt(true);
|
||||
if (slotCount == 0) return null;
|
||||
Skin skin = new Skin(skinName);
|
||||
@ -336,15 +336,15 @@ public class SkeletonBinary {
|
||||
int slotIndex = input.readInt(true);
|
||||
for (int ii = 0, nn = input.readInt(true); ii < nn; ii++) {
|
||||
String name = input.readString();
|
||||
Attachment attachment = readAttachment(input, skin, slotIndex, name, nonessential);
|
||||
Attachment attachment = readAttachment(input, skeletonData, skin, slotIndex, name, nonessential);
|
||||
if (attachment != null) skin.addAttachment(slotIndex, name, attachment);
|
||||
}
|
||||
}
|
||||
return skin;
|
||||
}
|
||||
|
||||
private Attachment readAttachment (DataInput input, Skin skin, int slotIndex, String attachmentName, boolean nonessential)
|
||||
throws IOException {
|
||||
private Attachment readAttachment (DataInput input, SkeletonData skeletonData, Skin skin, int slotIndex, String attachmentName,
|
||||
boolean nonessential) throws IOException {
|
||||
float scale = this.scale;
|
||||
|
||||
String name = input.readString();
|
||||
@ -494,7 +494,7 @@ public class SkeletonBinary {
|
||||
|
||||
ClippingAttachment clip = attachmentLoader.newClippingAttachment(skin, name);
|
||||
if (clip == null) return null;
|
||||
clip.setEndSlot(endSlotIndex);
|
||||
clip.setEndSlot(skeletonData.slots.get(endSlotIndex));
|
||||
clip.setWorldVerticesLength(vertexCount << 1);
|
||||
clip.setVertices(vertices.vertices);
|
||||
clip.setBones(vertices.bones);
|
||||
@ -549,7 +549,7 @@ public class SkeletonBinary {
|
||||
return array;
|
||||
}
|
||||
|
||||
private void readAnimation (String name, DataInput input, SkeletonData skeletonData) {
|
||||
private void readAnimation (DataInput input, String name, SkeletonData skeletonData) {
|
||||
Array<Timeline> timelines = new Array();
|
||||
float scale = this.scale;
|
||||
float duration = 0;
|
||||
|
||||
@ -414,8 +414,8 @@ public class SkeletonJson {
|
||||
String end = map.getString("end", null);
|
||||
if (end != null) {
|
||||
SlotData slot = skeletonData.findSlot(end);
|
||||
if (slot == null) throw new SerializationException("Slot not found: " + end);
|
||||
clip.setEndSlot(slot.index);
|
||||
if (slot == null) throw new SerializationException("Clipping end slot not found: " + end);
|
||||
clip.setEndSlot(slot);
|
||||
}
|
||||
|
||||
readVertices(map, clip, map.getInt("vertexCount") << 1);
|
||||
|
||||
@ -119,7 +119,7 @@ public class SkeletonRenderer implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
clipper.clipEnd(i);
|
||||
clipper.clipEnd(slot);
|
||||
}
|
||||
clipper.clipEnd();
|
||||
}
|
||||
@ -131,13 +131,13 @@ public class SkeletonRenderer implements Disposable {
|
||||
int verticesLength = 0;
|
||||
float[] vertices = null, uvs = null;
|
||||
short[] triangles = null;
|
||||
Texture texture = null;
|
||||
Color color = null, skeletonColor = skeleton.color;
|
||||
float r = skeletonColor.r, g = skeletonColor.g, b = skeletonColor.b, a = skeletonColor.a;
|
||||
Array<Slot> drawOrder = skeleton.drawOrder;
|
||||
for (int i = 0, n = drawOrder.size; i < n; i++) {
|
||||
int vertexSize = clipper.isClipping() ? 2 : 5;
|
||||
Slot slot = drawOrder.get(i);
|
||||
Texture texture = null;
|
||||
int vertexSize = clipper.isClipping() ? 2 : 5;
|
||||
Attachment attachment = slot.attachment;
|
||||
if (attachment instanceof RegionAttachment) {
|
||||
RegionAttachment region = (RegionAttachment)attachment;
|
||||
@ -221,7 +221,7 @@ public class SkeletonRenderer implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
clipper.clipEnd(i);
|
||||
clipper.clipEnd(slot);
|
||||
}
|
||||
clipper.clipEnd();
|
||||
}
|
||||
@ -233,12 +233,12 @@ public class SkeletonRenderer implements Disposable {
|
||||
int verticesLength = 0;
|
||||
float[] vertices = null, uvs = null;
|
||||
short[] triangles = null;
|
||||
Texture texture = null;
|
||||
Color color = null, skeletonColor = skeleton.color;
|
||||
float r = skeletonColor.r, g = skeletonColor.g, b = skeletonColor.b, a = skeletonColor.a;
|
||||
Array<Slot> drawOrder = skeleton.drawOrder;
|
||||
for (int i = 0, n = drawOrder.size; i < n; i++) {
|
||||
Slot slot = drawOrder.get(i);
|
||||
Texture texture = null;
|
||||
int vertexSize = clipper.isClipping() ? 2 : 6;
|
||||
Attachment attachment = slot.attachment;
|
||||
if (attachment instanceof RegionAttachment) {
|
||||
@ -254,7 +254,7 @@ public class SkeletonRenderer implements Disposable {
|
||||
} else if (attachment instanceof MeshAttachment) {
|
||||
MeshAttachment mesh = (MeshAttachment)attachment;
|
||||
int count = mesh.getWorldVerticesLength();
|
||||
verticesLength = count * (vertexSize >> 1);
|
||||
verticesLength = (count >> 1) * vertexSize;
|
||||
vertices = this.vertices.setSize(verticesLength);
|
||||
mesh.computeWorldVertices(slot, 0, count, vertices, 0, vertexSize);
|
||||
triangles = mesh.getTriangles();
|
||||
@ -330,7 +330,7 @@ public class SkeletonRenderer implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
clipper.clipEnd(i);
|
||||
clipper.clipEnd(slot);
|
||||
}
|
||||
clipper.clipEnd();
|
||||
}
|
||||
|
||||
@ -31,10 +31,11 @@
|
||||
package com.esotericsoftware.spine.attachments;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.esotericsoftware.spine.SlotData;
|
||||
|
||||
/** An attachment with vertices that make up a polygon used for clipping the rendering of other attachments. */
|
||||
public class ClippingAttachment extends VertexAttachment {
|
||||
int endSlot = -1;
|
||||
SlotData endSlot;
|
||||
|
||||
// Nonessential.
|
||||
final Color color = new Color(0.2275f, 0.2275f, 0.8078f, 1); // ce3a3aff
|
||||
@ -45,12 +46,12 @@ public class ClippingAttachment extends VertexAttachment {
|
||||
|
||||
/** Clipping is performed between the clipping polygon's slot and the end slot. Returns -1 if clipping is done until the end of
|
||||
* the skeleton's rendering. */
|
||||
public int getEndSlot () {
|
||||
public SlotData getEndSlot () {
|
||||
return endSlot;
|
||||
}
|
||||
|
||||
public void setEndSlot (int slotIndex) {
|
||||
this.endSlot = slotIndex;
|
||||
public void setEndSlot (SlotData endSlot) {
|
||||
this.endSlot = endSlot;
|
||||
}
|
||||
|
||||
/** The color of the clipping polygon as it was in Spine. Available only when nonessential data was exported. Clipping polygons
|
||||
|
||||
@ -63,8 +63,8 @@ public class SkeletonClipping {
|
||||
}
|
||||
}
|
||||
|
||||
public void clipEnd (int index) {
|
||||
if (clipAttachment != null && clipAttachment.getEndSlot() == index) clipEnd();
|
||||
public void clipEnd (Slot slot) {
|
||||
if (clipAttachment != null && clipAttachment.getEndSlot() == slot.getData()) clipEnd();
|
||||
}
|
||||
|
||||
public void clipEnd () {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user