|
@@ -31,6 +31,7 @@ using System;
|
|
|
|
|
|
namespace Spine {
|
|
namespace Spine {
|
|
public class Skeleton {
|
|
public class Skeleton {
|
|
|
|
+ static private readonly int[] quadTriangles = { 0, 1, 2, 2, 3, 0 };
|
|
internal SkeletonData data;
|
|
internal SkeletonData data;
|
|
internal ExposedList<Bone> bones;
|
|
internal ExposedList<Bone> bones;
|
|
internal ExposedList<Slot> slots;
|
|
internal ExposedList<Slot> slots;
|
|
@@ -696,7 +697,9 @@ namespace Spine {
|
|
/// <param name="width">The width of the AABB</param>
|
|
/// <param name="width">The width of the AABB</param>
|
|
/// <param name="height">The height of the AABB.</param>
|
|
/// <param name="height">The height of the AABB.</param>
|
|
/// <param name="vertexBuffer">Reference to hold a float[]. May be a null reference. This method will assign it a new float[] with the appropriate size as needed.</param>
|
|
/// <param name="vertexBuffer">Reference to hold a float[]. May be a null reference. This method will assign it a new float[] with the appropriate size as needed.</param>
|
|
- public void GetBounds (out float x, out float y, out float width, out float height, ref float[] vertexBuffer) {
|
|
|
|
|
|
+ public void GetBounds (out float x, out float y, out float width, out float height, ref float[] vertexBuffer,
|
|
|
|
+ SkeletonClipping clipper = null) {
|
|
|
|
+
|
|
float[] temp = vertexBuffer;
|
|
float[] temp = vertexBuffer;
|
|
temp = temp ?? new float[8];
|
|
temp = temp ?? new float[8];
|
|
Slot[] drawOrder = this.drawOrder.Items;
|
|
Slot[] drawOrder = this.drawOrder.Items;
|
|
@@ -706,6 +709,7 @@ namespace Spine {
|
|
if (!slot.bone.active) continue;
|
|
if (!slot.bone.active) continue;
|
|
int verticesLength = 0;
|
|
int verticesLength = 0;
|
|
float[] vertices = null;
|
|
float[] vertices = null;
|
|
|
|
+ int[] triangles = null;
|
|
Attachment attachment = slot.attachment;
|
|
Attachment attachment = slot.attachment;
|
|
RegionAttachment region = attachment as RegionAttachment;
|
|
RegionAttachment region = attachment as RegionAttachment;
|
|
if (region != null) {
|
|
if (region != null) {
|
|
@@ -713,6 +717,7 @@ namespace Spine {
|
|
vertices = temp;
|
|
vertices = temp;
|
|
if (vertices.Length < 8) vertices = temp = new float[8];
|
|
if (vertices.Length < 8) vertices = temp = new float[8];
|
|
region.ComputeWorldVertices(slot, temp, 0, 2);
|
|
region.ComputeWorldVertices(slot, temp, 0, 2);
|
|
|
|
+ triangles = quadTriangles;
|
|
} else {
|
|
} else {
|
|
MeshAttachment mesh = attachment as MeshAttachment;
|
|
MeshAttachment mesh = attachment as MeshAttachment;
|
|
if (mesh != null) {
|
|
if (mesh != null) {
|
|
@@ -720,10 +725,23 @@ namespace Spine {
|
|
vertices = temp;
|
|
vertices = temp;
|
|
if (vertices.Length < verticesLength) vertices = temp = new float[verticesLength];
|
|
if (vertices.Length < verticesLength) vertices = temp = new float[verticesLength];
|
|
mesh.ComputeWorldVertices(slot, 0, verticesLength, temp, 0, 2);
|
|
mesh.ComputeWorldVertices(slot, 0, verticesLength, temp, 0, 2);
|
|
|
|
+ triangles = mesh.Triangles;
|
|
|
|
+ } else if (clipper != null) {
|
|
|
|
+ ClippingAttachment clip = attachment as ClippingAttachment;
|
|
|
|
+ if (clip != null) {
|
|
|
|
+ clipper.ClipStart(slot, clip);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if (vertices != null) {
|
|
if (vertices != null) {
|
|
|
|
+ if (clipper != null && clipper.IsClipping) {
|
|
|
|
+ clipper.ClipTriangles(vertices, verticesLength, triangles, triangles.Length);
|
|
|
|
+ vertices = clipper.ClippedVertices.Items;
|
|
|
|
+ verticesLength = clipper.ClippedVertices.Count;
|
|
|
|
+ }
|
|
|
|
+
|
|
for (int ii = 0; ii < verticesLength; ii += 2) {
|
|
for (int ii = 0; ii < verticesLength; ii += 2) {
|
|
float vx = vertices[ii], vy = vertices[ii + 1];
|
|
float vx = vertices[ii], vy = vertices[ii + 1];
|
|
minX = Math.Min(minX, vx);
|
|
minX = Math.Min(minX, vx);
|
|
@@ -732,7 +750,9 @@ namespace Spine {
|
|
maxY = Math.Max(maxY, vy);
|
|
maxY = Math.Max(maxY, vy);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (clipper != null) clipper.ClipEnd(slot);
|
|
}
|
|
}
|
|
|
|
+ if (clipper != null) clipper.ClipEnd();
|
|
x = minX;
|
|
x = minX;
|
|
y = minY;
|
|
y = minY;
|
|
width = maxX - minX;
|
|
width = maxX - minX;
|