mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-11 17:48:45 +08:00
Fixed additive blending for meshes.
This commit is contained in:
parent
3ff8661670
commit
03c957f55e
@ -47,6 +47,7 @@ public class SkeletonRenderer {
|
||||
|
||||
private boolean premultipliedAlpha;
|
||||
|
||||
@SuppressWarnings("null")
|
||||
public void draw (PolygonSpriteBatch batch, Skeleton skeleton) {
|
||||
boolean premultipliedAlpha = this.premultipliedAlpha;
|
||||
int srcFunc = premultipliedAlpha ? GL20.GL_ONE : GL20.GL_SRC_ALPHA;
|
||||
@ -54,13 +55,13 @@ public class SkeletonRenderer {
|
||||
|
||||
boolean additive = false;
|
||||
|
||||
float[] vertices;
|
||||
short[] triangles;
|
||||
Texture texture;
|
||||
float[] vertices = null;
|
||||
short[] triangles = null;
|
||||
Array<Slot> drawOrder = skeleton.drawOrder;
|
||||
for (int i = 0, n = drawOrder.size; i < n; i++) {
|
||||
Slot slot = drawOrder.get(i);
|
||||
Attachment attachment = slot.attachment;
|
||||
Texture texture = null;
|
||||
if (attachment instanceof RegionAttachment) {
|
||||
RegionAttachment region = (RegionAttachment)attachment;
|
||||
region.updateWorldVertices(slot, premultipliedAlpha);
|
||||
@ -68,23 +69,12 @@ public class SkeletonRenderer {
|
||||
triangles = quadTriangles;
|
||||
texture = region.getRegion().getTexture();
|
||||
|
||||
if (slot.data.getAdditiveBlending() != additive) {
|
||||
additive = !additive;
|
||||
if (additive)
|
||||
batch.setBlendFunction(srcFunc, GL20.GL_ONE);
|
||||
else
|
||||
batch.setBlendFunction(srcFunc, GL20.GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
|
||||
batch.draw(texture, vertices, 0, vertices.length, triangles, 0, triangles.length);
|
||||
|
||||
} else if (attachment instanceof MeshAttachment) {
|
||||
MeshAttachment mesh = (MeshAttachment)attachment;
|
||||
mesh.updateWorldVertices(slot, true);
|
||||
vertices = mesh.getWorldVertices();
|
||||
triangles = mesh.getTriangles();
|
||||
texture = mesh.getRegion().getTexture();
|
||||
batch.draw(texture, vertices, 0, vertices.length, triangles, 0, triangles.length);
|
||||
|
||||
} else if (attachment instanceof SkinnedMeshAttachment) {
|
||||
SkinnedMeshAttachment mesh = (SkinnedMeshAttachment)attachment;
|
||||
@ -92,7 +82,6 @@ public class SkeletonRenderer {
|
||||
vertices = mesh.getWorldVertices();
|
||||
triangles = mesh.getTriangles();
|
||||
texture = mesh.getRegion().getTexture();
|
||||
batch.draw(texture, vertices, 0, vertices.length, triangles, 0, triangles.length);
|
||||
|
||||
} else if (attachment instanceof SkeletonAttachment) {
|
||||
Skeleton attachmentSkeleton = ((SkeletonAttachment)attachment).getSkeleton();
|
||||
@ -117,6 +106,17 @@ public class SkeletonRenderer {
|
||||
rootBone.setScaleY(oldScaleY);
|
||||
rootBone.setRotation(oldRotation);
|
||||
}
|
||||
|
||||
if (texture != null) {
|
||||
if (slot.data.getAdditiveBlending() != additive) {
|
||||
additive = !additive;
|
||||
if (additive)
|
||||
batch.setBlendFunction(srcFunc, GL20.GL_ONE);
|
||||
else
|
||||
batch.setBlendFunction(srcFunc, GL20.GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
batch.draw(texture, vertices, 0, vertices.length, triangles, 0, triangles.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user