[libgdx] Fixed NPE when a mesh has no region.

This commit is contained in:
NathanSweet 2019-04-18 21:04:03 +02:00
parent bf93b00e6b
commit 51d6681db4

View File

@ -75,8 +75,10 @@ public class MeshAttachment extends VertexAttachment {
if (this.uvs == null || this.uvs.length != regionUVs.length) this.uvs = new float[regionUVs.length]; if (this.uvs == null || this.uvs.length != regionUVs.length) this.uvs = new float[regionUVs.length];
float[] uvs = this.uvs; float[] uvs = this.uvs;
int n = uvs.length; int n = uvs.length;
float u = region.getU(), v = region.getV(), width, height; float u, v, width, height;
if (region instanceof AtlasRegion) { if (region instanceof AtlasRegion) {
u = region.getU();
v = region.getV();
AtlasRegion region = (AtlasRegion)this.region; AtlasRegion region = (AtlasRegion)this.region;
float textureWidth = region.getTexture().getWidth(), textureHeight = region.getTexture().getHeight(); float textureWidth = region.getTexture().getWidth(), textureHeight = region.getTexture().getHeight();
switch (region.degrees) { switch (region.degrees) {
@ -119,6 +121,8 @@ public class MeshAttachment extends VertexAttachment {
u = v = 0; u = v = 0;
width = height = 1; width = height = 1;
} else { } else {
u = region.getU();
v = region.getV();
width = region.getU2() - u; width = region.getU2() - u;
height = region.getV2() - v; height = region.getV2() - v;
} }