mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-25 22:23:42 +08:00
[libgdx] Wrap System.arraycopy for exceptions with more context.
This commit is contained in:
parent
28862c94bc
commit
ad6ed0911c
@ -31,6 +31,7 @@ package com.esotericsoftware.spine;
|
|||||||
|
|
||||||
import static com.esotericsoftware.spine.Animation.MixBlend.*;
|
import static com.esotericsoftware.spine.Animation.MixBlend.*;
|
||||||
import static com.esotericsoftware.spine.Animation.MixDirection.*;
|
import static com.esotericsoftware.spine.Animation.MixDirection.*;
|
||||||
|
import static com.esotericsoftware.spine.utils.SpineUtils.*;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
@ -1067,7 +1068,7 @@ public class Animation {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Vertex positions or deform offsets, no alpha.
|
// Vertex positions or deform offsets, no alpha.
|
||||||
System.arraycopy(lastVertices, 0, deform, 0, vertexCount);
|
arraycopy(lastVertices, 0, deform, 0, vertexCount);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (blend) {
|
switch (blend) {
|
||||||
@ -1299,13 +1300,13 @@ public class Animation {
|
|||||||
Array<Slot> drawOrder = skeleton.drawOrder;
|
Array<Slot> drawOrder = skeleton.drawOrder;
|
||||||
Array<Slot> slots = skeleton.slots;
|
Array<Slot> slots = skeleton.slots;
|
||||||
if (direction == out && blend == setup) {
|
if (direction == out && blend == setup) {
|
||||||
System.arraycopy(slots.items, 0, drawOrder.items, 0, slots.size);
|
arraycopy(slots.items, 0, drawOrder.items, 0, slots.size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float[] frames = this.frames;
|
float[] frames = this.frames;
|
||||||
if (time < frames[0]) { // Time is before first frame.
|
if (time < frames[0]) { // Time is before first frame.
|
||||||
if (blend == setup || blend == first) System.arraycopy(slots.items, 0, drawOrder.items, 0, slots.size);
|
if (blend == setup || blend == first) arraycopy(slots.items, 0, drawOrder.items, 0, slots.size);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1317,7 +1318,7 @@ public class Animation {
|
|||||||
|
|
||||||
int[] drawOrderToSetupIndex = drawOrders[frame];
|
int[] drawOrderToSetupIndex = drawOrders[frame];
|
||||||
if (drawOrderToSetupIndex == null)
|
if (drawOrderToSetupIndex == null)
|
||||||
System.arraycopy(slots.items, 0, drawOrder.items, 0, slots.size);
|
arraycopy(slots.items, 0, drawOrder.items, 0, slots.size);
|
||||||
else {
|
else {
|
||||||
for (int i = 0, n = drawOrderToSetupIndex.length; i < n; i++)
|
for (int i = 0, n = drawOrderToSetupIndex.length; i < n; i++)
|
||||||
drawOrder.set(i, slots.get(drawOrderToSetupIndex[i]));
|
drawOrder.set(i, slots.get(drawOrderToSetupIndex[i]));
|
||||||
|
|||||||
@ -448,7 +448,7 @@ public class Skeleton {
|
|||||||
/** Sets the slots and draw order to their setup pose values. */
|
/** Sets the slots and draw order to their setup pose values. */
|
||||||
public void setSlotsToSetupPose () {
|
public void setSlotsToSetupPose () {
|
||||||
Array<Slot> slots = this.slots;
|
Array<Slot> slots = this.slots;
|
||||||
System.arraycopy(slots.items, 0, drawOrder.items, 0, slots.size);
|
arraycopy(slots.items, 0, drawOrder.items, 0, slots.size);
|
||||||
for (int i = 0, n = slots.size; i < n; i++)
|
for (int i = 0, n = slots.size; i < n; i++)
|
||||||
slots.get(i).setToSetupPose();
|
slots.get(i).setToSetupPose();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
package com.esotericsoftware.spine;
|
package com.esotericsoftware.spine;
|
||||||
|
|
||||||
|
import static com.esotericsoftware.spine.utils.SpineUtils.*;
|
||||||
|
|
||||||
import com.badlogic.gdx.files.FileHandle;
|
import com.badlogic.gdx.files.FileHandle;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||||
@ -38,6 +40,7 @@ import com.badlogic.gdx.utils.IntArray;
|
|||||||
import com.badlogic.gdx.utils.JsonReader;
|
import com.badlogic.gdx.utils.JsonReader;
|
||||||
import com.badlogic.gdx.utils.JsonValue;
|
import com.badlogic.gdx.utils.JsonValue;
|
||||||
import com.badlogic.gdx.utils.SerializationException;
|
import com.badlogic.gdx.utils.SerializationException;
|
||||||
|
|
||||||
import com.esotericsoftware.spine.Animation.AttachmentTimeline;
|
import com.esotericsoftware.spine.Animation.AttachmentTimeline;
|
||||||
import com.esotericsoftware.spine.Animation.ColorTimeline;
|
import com.esotericsoftware.spine.Animation.ColorTimeline;
|
||||||
import com.esotericsoftware.spine.Animation.CurveTimeline;
|
import com.esotericsoftware.spine.Animation.CurveTimeline;
|
||||||
@ -702,7 +705,7 @@ public class SkeletonJson {
|
|||||||
else {
|
else {
|
||||||
deform = new float[deformLength];
|
deform = new float[deformLength];
|
||||||
int start = valueMap.getInt("offset", 0);
|
int start = valueMap.getInt("offset", 0);
|
||||||
System.arraycopy(verticesValue.asFloatArray(), 0, deform, start, verticesValue.size);
|
arraycopy(verticesValue.asFloatArray(), 0, deform, start, verticesValue.size);
|
||||||
if (scale != 1) {
|
if (scale != 1) {
|
||||||
for (int i = start, n = i + verticesValue.size; i < n; i++)
|
for (int i = start, n = i + verticesValue.size; i < n; i++)
|
||||||
deform[i] *= scale;
|
deform[i] *= scale;
|
||||||
|
|||||||
@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
package com.esotericsoftware.spine.attachments;
|
package com.esotericsoftware.spine.attachments;
|
||||||
|
|
||||||
|
import static com.esotericsoftware.spine.utils.SpineUtils.*;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
@ -242,17 +244,17 @@ public class MeshAttachment extends VertexAttachment {
|
|||||||
|
|
||||||
copyTo(copy);
|
copyTo(copy);
|
||||||
copy.regionUVs = new float[regionUVs.length];
|
copy.regionUVs = new float[regionUVs.length];
|
||||||
System.arraycopy(regionUVs, 0, copy.regionUVs, 0, regionUVs.length);
|
arraycopy(regionUVs, 0, copy.regionUVs, 0, regionUVs.length);
|
||||||
copy.uvs = new float[uvs.length];
|
copy.uvs = new float[uvs.length];
|
||||||
System.arraycopy(uvs, 0, copy.uvs, 0, uvs.length);
|
arraycopy(uvs, 0, copy.uvs, 0, uvs.length);
|
||||||
copy.triangles = new short[triangles.length];
|
copy.triangles = new short[triangles.length];
|
||||||
System.arraycopy(triangles, 0, copy.triangles, 0, triangles.length);
|
arraycopy(triangles, 0, copy.triangles, 0, triangles.length);
|
||||||
copy.hullLength = hullLength;
|
copy.hullLength = hullLength;
|
||||||
|
|
||||||
// Nonessential.
|
// Nonessential.
|
||||||
if (edges != null) {
|
if (edges != null) {
|
||||||
copy.edges = new short[edges.length];
|
copy.edges = new short[edges.length];
|
||||||
System.arraycopy(edges, 0, copy.edges, 0, edges.length);
|
arraycopy(edges, 0, copy.edges, 0, edges.length);
|
||||||
}
|
}
|
||||||
copy.width = width;
|
copy.width = width;
|
||||||
copy.height = height;
|
copy.height = height;
|
||||||
|
|||||||
@ -29,7 +29,10 @@
|
|||||||
|
|
||||||
package com.esotericsoftware.spine.attachments;
|
package com.esotericsoftware.spine.attachments;
|
||||||
|
|
||||||
|
import static com.esotericsoftware.spine.utils.SpineUtils.*;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
|
|
||||||
import com.esotericsoftware.spine.PathConstraint;
|
import com.esotericsoftware.spine.PathConstraint;
|
||||||
|
|
||||||
/** An attachment whose vertices make up a composite Bezier curve.
|
/** An attachment whose vertices make up a composite Bezier curve.
|
||||||
@ -84,7 +87,7 @@ public class PathAttachment extends VertexAttachment {
|
|||||||
PathAttachment copy = new PathAttachment(name);
|
PathAttachment copy = new PathAttachment(name);
|
||||||
copyTo(copy);
|
copyTo(copy);
|
||||||
copy.lengths = new float[lengths.length];
|
copy.lengths = new float[lengths.length];
|
||||||
System.arraycopy(lengths, 0, copy.lengths, 0, lengths.length);
|
arraycopy(lengths, 0, copy.lengths, 0, lengths.length);
|
||||||
copy.closed = closed;
|
copy.closed = closed;
|
||||||
copy.constantSpeed = constantSpeed;
|
copy.constantSpeed = constantSpeed;
|
||||||
copy.color.set(color);
|
copy.color.set(color);
|
||||||
|
|||||||
@ -29,10 +29,13 @@
|
|||||||
|
|
||||||
package com.esotericsoftware.spine.attachments;
|
package com.esotericsoftware.spine.attachments;
|
||||||
|
|
||||||
|
import static com.esotericsoftware.spine.utils.SpineUtils.*;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
|
|
||||||
import com.esotericsoftware.spine.Bone;
|
import com.esotericsoftware.spine.Bone;
|
||||||
|
|
||||||
/** An attachment that displays a textured quadrilateral.
|
/** An attachment that displays a textured quadrilateral.
|
||||||
@ -275,8 +278,8 @@ public class RegionAttachment extends Attachment {
|
|||||||
copy.rotation = rotation;
|
copy.rotation = rotation;
|
||||||
copy.width = width;
|
copy.width = width;
|
||||||
copy.height = height;
|
copy.height = height;
|
||||||
System.arraycopy(uvs, 0, copy.uvs, 0, 8);
|
arraycopy(uvs, 0, copy.uvs, 0, 8);
|
||||||
System.arraycopy(offset, 0, copy.offset, 0, 8);
|
arraycopy(offset, 0, copy.offset, 0, 8);
|
||||||
copy.color.set(color);
|
copy.color.set(color);
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,10 @@
|
|||||||
|
|
||||||
package com.esotericsoftware.spine.attachments;
|
package com.esotericsoftware.spine.attachments;
|
||||||
|
|
||||||
|
import static com.esotericsoftware.spine.utils.SpineUtils.*;
|
||||||
|
|
||||||
import com.badlogic.gdx.utils.FloatArray;
|
import com.badlogic.gdx.utils.FloatArray;
|
||||||
|
|
||||||
import com.esotericsoftware.spine.Bone;
|
import com.esotericsoftware.spine.Bone;
|
||||||
import com.esotericsoftware.spine.Skeleton;
|
import com.esotericsoftware.spine.Skeleton;
|
||||||
import com.esotericsoftware.spine.Slot;
|
import com.esotericsoftware.spine.Slot;
|
||||||
@ -170,13 +173,13 @@ abstract public class VertexAttachment extends Attachment {
|
|||||||
void copyTo (VertexAttachment attachment) {
|
void copyTo (VertexAttachment attachment) {
|
||||||
if (bones != null) {
|
if (bones != null) {
|
||||||
attachment.bones = new int[bones.length];
|
attachment.bones = new int[bones.length];
|
||||||
System.arraycopy(bones, 0, attachment.bones, 0, bones.length);
|
arraycopy(bones, 0, attachment.bones, 0, bones.length);
|
||||||
} else
|
} else
|
||||||
attachment.bones = null;
|
attachment.bones = null;
|
||||||
|
|
||||||
if (vertices != null) {
|
if (vertices != null) {
|
||||||
attachment.vertices = new float[vertices.length];
|
attachment.vertices = new float[vertices.length];
|
||||||
System.arraycopy(vertices, 0, attachment.vertices, 0, vertices.length);
|
arraycopy(vertices, 0, attachment.vertices, 0, vertices.length);
|
||||||
} else
|
} else
|
||||||
attachment.vertices = null;
|
attachment.vertices = null;
|
||||||
|
|
||||||
|
|||||||
@ -56,4 +56,17 @@ public class SpineUtils {
|
|||||||
public static float atan2 (float y, float x) {
|
public static float atan2 (float y, float x) {
|
||||||
return (float)Math.atan2(y, x);
|
return (float)Math.atan2(y, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static public void arraycopy (Object src, int srcPos, Object dest, int destPos, int length) {
|
||||||
|
if (src == null) throw new IllegalArgumentException("src cannot be null.");
|
||||||
|
if (dest == null) throw new IllegalArgumentException("dest cannot be null.");
|
||||||
|
try {
|
||||||
|
System.arraycopy(src, srcPos, dest, destPos, length);
|
||||||
|
} catch (ArrayIndexOutOfBoundsException ex) {
|
||||||
|
throw new ArrayIndexOutOfBoundsException( //
|
||||||
|
"Src: " + java.lang.reflect.Array.getLength(src) + ", " + srcPos //
|
||||||
|
+ ", dest: " + java.lang.reflect.Array.getLength(dest) + ", " + destPos //
|
||||||
|
+ ", count: " + length);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
package com.esotericsoftware.spine.utils;
|
package com.esotericsoftware.spine.utils;
|
||||||
|
|
||||||
|
import static com.esotericsoftware.spine.utils.SpineUtils.*;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
@ -754,7 +756,7 @@ public class TwoColorPolygonBatch implements PolygonBatch {
|
|||||||
triangles[triangleIndex++] = (short)(polygonTriangles[i] + startVertex);
|
triangles[triangleIndex++] = (short)(polygonTriangles[i] + startVertex);
|
||||||
this.triangleIndex = triangleIndex;
|
this.triangleIndex = triangleIndex;
|
||||||
|
|
||||||
System.arraycopy(polygonVertices, verticesOffset, vertices, vertexIndex, verticesCount);
|
arraycopy(polygonVertices, verticesOffset, vertices, vertexIndex, verticesCount);
|
||||||
this.vertexIndex += verticesCount;
|
this.vertexIndex += verticesCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -821,7 +823,7 @@ public class TwoColorPolygonBatch implements PolygonBatch {
|
|||||||
}
|
}
|
||||||
this.triangleIndex = triangleIndex;
|
this.triangleIndex = triangleIndex;
|
||||||
|
|
||||||
System.arraycopy(spriteVertices, offset, vertices, vertexIndex, count);
|
arraycopy(spriteVertices, offset, vertices, vertexIndex, count);
|
||||||
this.vertexIndex += count;
|
this.vertexIndex += count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user