Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AIOOBE for non-quad Faces #15

Merged
merged 1 commit into from
Mar 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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