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