Skip to content

Commit

Permalink
Fix AIOOBE for non-quad Faces (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
ah-OOG-ah authored Mar 31, 2024
1 parent ca738fd commit f830c53
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/net/malisis/core/renderer/element/Face.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class Face implements ITransformable.Translate, ITransformable.Rotate {
protected String name;
protected Vertex[] vertexes;
protected RenderParameters params = new RenderParameters();
private final float[][] scratch = new float[4][2];
private float[][] scratch;
private static final int[] dirs = { Vertex.NORTH, Vertex.SOUTH, Vertex.EAST, Vertex.WEST, Vertex.UP, Vertex.DOWN };
private static final String[] strdirs = { "North", "South", "East", "West", "Top", "Bottom" };

Expand All @@ -38,6 +38,7 @@ public void reset() {

public Face(Vertex[] vertexes, RenderParameters params) {
this.vertexes = vertexes;
this.scratch = new float[vertexes.length][2];
this.params = params != null ? params : this.params;
this.setName(null);
}
Expand All @@ -57,6 +58,7 @@ public Face(Face face) {
public Face(Face face, RenderParameters params) {
Vertex[] faceVertexes = face.getVertexes();
this.vertexes = new Vertex[faceVertexes.length];
this.scratch = new float[faceVertexes.length][2];
for (int i = 0; i < faceVertexes.length; i++) vertexes[i] = new Vertex(faceVertexes[i]);
this.params = params != null ? params : this.params;
name = face.name;
Expand All @@ -68,6 +70,7 @@ public void copy(Face f) {
boolean init = false;
if (this.vertexes.length != f.vertexes.length) {
this.vertexes = new Vertex[f.vertexes.length];
this.scratch = new float[f.vertexes.length][2];
init = true;
}

Expand Down

0 comments on commit f830c53

Please sign in to comment.