mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 01:06:00 +08:00
[android] Clipping support.
This commit is contained in:
parent
538c4ed58e
commit
8b162ad1c5
@ -24,11 +24,11 @@ dependencyResolutionManagement {
|
||||
}
|
||||
|
||||
rootProject.name = "Spine Android Examples"
|
||||
//includeBuild("../spine-libgdx") {
|
||||
// dependencySubstitution {
|
||||
// substitute(module("com.esotericsoftware.spine:spine-libgdx")).using(project(":spine-libgdx"))
|
||||
// }
|
||||
//}
|
||||
includeBuild("../spine-libgdx") {
|
||||
dependencySubstitution {
|
||||
substitute(module("com.esotericsoftware.spine:spine-libgdx")).using(project(":spine-libgdx"))
|
||||
}
|
||||
}
|
||||
//includeBuild("../../libgdx") {
|
||||
// dependencySubstitution {
|
||||
// substitute(module("com.badlogicgames.gdx:gdx")).using(project(":gdx"))
|
||||
|
||||
@ -40,7 +40,7 @@ dependencies {
|
||||
androidTestImplementation(libs.androidx.espresso.core)
|
||||
}
|
||||
|
||||
val libraryVersion = "4.2.3-SNAPSHOT" // Update this as needed
|
||||
val libraryVersion = "4.2.3" // Update this as needed
|
||||
|
||||
tasks.register<Jar>("sourceJar") {
|
||||
archiveClassifier.set("sources")
|
||||
@ -122,9 +122,11 @@ afterEvaluate {
|
||||
}
|
||||
}
|
||||
|
||||
signing {
|
||||
useGpgCmd()
|
||||
sign(publishing.publications["release"])
|
||||
sign(tasks.getByName("sourceJar"))
|
||||
if (!libraryVersion.endsWith("-SNAPSHOT")) {
|
||||
signing {
|
||||
useGpgCmd()
|
||||
sign(publishing.publications["release"])
|
||||
sign(tasks.getByName("sourceJar"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,38 +177,56 @@ public class SkeletonRenderer {
|
||||
| (int)(g * slotColor.g * color.g * 255) << 8 //
|
||||
| (int)(b * slotColor.b * color.b * 255);
|
||||
|
||||
int indicesStart = command.indices.size;
|
||||
int indicesLength = indices.length;
|
||||
if (clipper.isClipping()) {
|
||||
// FIXME
|
||||
throw new RuntimeException("Not implemented, need to split positions, uvs, colors");
|
||||
// clipper.clipTriangles(vertices, verticesLength, triangles, triangles.length, uvs, c, 0, false);
|
||||
// FloatArray clippedVertices = clipper.getClippedVertices();
|
||||
// ShortArray clippedTriangles = clipper.getClippedTriangles();
|
||||
// batch.draw(texture, clippedVertices.items, 0, clippedVertices.size, clippedTriangles.items, 0,
|
||||
// clippedTriangles.size);
|
||||
clipper.clipTrianglesUnpacked(command.vertices.items, vertexStart, indices, indices.length, uvs);
|
||||
|
||||
// Copy clipped vertices over, overwritting the previous vertices of this attachment
|
||||
FloatArray clippedVertices = clipper.getClippedVertices();
|
||||
command.vertices.setSize(vertexStart + clippedVertices.size);
|
||||
System.arraycopy(clippedVertices.items, 0, command.vertices.items, vertexStart, clippedVertices.size);
|
||||
|
||||
// Copy UVs over, post-processing below
|
||||
command.uvs.addAll(clipper.getClippedUvs());
|
||||
|
||||
// Copy indices over, post-processing below
|
||||
command.indices.addAll(clipper.getClippedTriangles());
|
||||
|
||||
// Update verticesLength with the clipped number of vertices * 2, and indices length
|
||||
// with the number of clipped indices.
|
||||
verticesLength = clippedVertices.size;
|
||||
indicesLength = clipper.getClippedTriangles().size;
|
||||
} else {
|
||||
// Copy UVs over, post-processing below
|
||||
command.uvs.addAll(uvs);
|
||||
float[] uvsArray = command.uvs.items;
|
||||
for (int ii = vertexStart, w = command.texture.getWidth(), h = command.texture.getHeight(),
|
||||
nn = vertexStart + verticesLength; ii < nn; ii += 2) {
|
||||
uvsArray[ii] = uvsArray[ii] * w;
|
||||
uvsArray[ii + 1] = uvsArray[ii + 1] * h;
|
||||
}
|
||||
|
||||
command.colors.setSize(command.colors.size + (verticesLength >> 1));
|
||||
int[] colorsArray = command.colors.items;
|
||||
for (int ii = vertexStart >> 1, nn = (vertexStart >> 1) + (verticesLength >> 1); ii < nn; ii++) {
|
||||
colorsArray[ii] = c;
|
||||
}
|
||||
|
||||
int indicesStart = command.indices.size;
|
||||
// Copy indices over, post-processing below
|
||||
command.indices.addAll(indices);
|
||||
int firstIndex = vertexStart >> 1;
|
||||
short[] indicesArray = command.indices.items;
|
||||
for (int ii = indicesStart, nn = indicesStart + indices.length; ii < nn; ii++) {
|
||||
indicesArray[ii] += firstIndex;
|
||||
}
|
||||
}
|
||||
// FIXME wrt clipping
|
||||
|
||||
// Post-process UVs, require scaling by bitmap size
|
||||
float[] uvsArray = command.uvs.items;
|
||||
for (int ii = vertexStart, w = command.texture.getWidth(), h = command.texture.getHeight(),
|
||||
nn = vertexStart + verticesLength; ii < nn; ii += 2) {
|
||||
uvsArray[ii] = uvsArray[ii] * w;
|
||||
uvsArray[ii + 1] = uvsArray[ii + 1] * h;
|
||||
}
|
||||
|
||||
// Fill colors array
|
||||
command.colors.setSize(command.colors.size + (verticesLength >> 1));
|
||||
int[] colorsArray = command.colors.items;
|
||||
for (int ii = vertexStart >> 1, nn = (vertexStart >> 1) + (verticesLength >> 1); ii < nn; ii++) {
|
||||
colorsArray[ii] = c;
|
||||
}
|
||||
|
||||
// Post-process indices array, need to be offset by index of the mesh's first vertex.
|
||||
int firstIndex = vertexStart >> 1;
|
||||
short[] indicesArray = command.indices.items;
|
||||
for (int ii = indicesStart, nn = indicesStart + indicesLength; ii < nn; ii++) {
|
||||
indicesArray[ii] += firstIndex;
|
||||
}
|
||||
|
||||
vertexStart += verticesLength;
|
||||
clipper.clipEnd(slot);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user