gpu: fix anim array indexes with sparse texture array

Texture 54 doesn't exist and was causing everything after it to have its index off by 1
This commit is contained in:
Adam
2022-03-02 14:20:03 -05:00
parent 2520da4dca
commit 5006e959b0

View File

@@ -208,35 +208,37 @@ class TextureManager
{ {
Texture[] textures = textureProvider.getTextures(); Texture[] textures = textureProvider.getTextures();
float[] anims = new float[TEXTURE_SIZE * 2]; float[] anims = new float[TEXTURE_SIZE * 2];
int idx = 0; for (int i = 0; i < textures.length; ++i)
for (Texture texture : textures)
{ {
if (texture != null) Texture texture = textures[i];
if (texture == null)
{ {
float u = 0f, v = 0f; continue;
switch (texture.getAnimationDirection())
{
case 1:
v = -1f;
break;
case 3:
v = 1f;
break;
case 2:
u = -1f;
break;
case 4:
u = 1f;
break;
}
int speed = texture.getAnimationSpeed();
u *= speed;
v *= speed;
anims[idx++] = u;
anims[idx++] = v;
} }
float u = 0f, v = 0f;
switch (texture.getAnimationDirection())
{
case 1:
v = -1f;
break;
case 3:
v = 1f;
break;
case 2:
u = -1f;
break;
case 4:
u = 1f;
break;
}
int speed = texture.getAnimationSpeed();
u *= speed;
v *= speed;
anims[i * 2] = u;
anims[i * 2 + 1] = v;
} }
return anims; return anims;
} }