Skip to content

Commit

Permalink
Merge pull request CaffeineMC#2060 from embeddedt/ignore-undersized-q…
Browse files Browse the repository at this point in the history
…uads

Ignore undersized quads
  • Loading branch information
IMS212 authored Sep 18, 2023
2 parents 4539ebf + 64ef95c commit 42bb21e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public void quad(MatrixStack.Entry matrices, BakedQuad bakedQuad, float r, float
throw new IllegalStateException();
}

if (bakedQuad.getVertexData().length < 32) {
return; // we do not accept quads with less than 4 properly sized vertices
}

VertexBufferWriter writer = VertexBufferWriter.of(this);

ModelQuadView quad = (ModelQuadView) bakedQuad;
Expand All @@ -56,6 +60,10 @@ public void quad(MatrixStack.Entry matrices, BakedQuad bakedQuad, float[] bright
throw new IllegalStateException();
}

if (bakedQuad.getVertexData().length < 32) {
return; // we do not accept quads with less than 4 properly sized vertices
}

VertexBufferWriter writer = VertexBufferWriter.of(this);

ModelQuadView quad = (ModelQuadView) bakedQuad;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ private void renderFast(MatrixStack.Entry entry, VertexConsumer vertexConsumer,
private static void renderQuads(MatrixStack.Entry matrices, VertexBufferWriter writer, int defaultColor, List<BakedQuad> quads, int light, int overlay) {
for (int i = 0; i < quads.size(); i++) {
BakedQuad bakedQuad = quads.get(i);

if (bakedQuad.getVertexData().length < 32) {
continue; // ignore bad quads
}

BakedQuadView quad = (BakedQuadView) bakedQuad;

int color = quad.hasColor() ? defaultColor : 0xFFFFFFFF;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ private void renderModelFast(BakedModel model, ItemStack itemStack, int light, i
private void renderBakedItemQuads(MatrixStack.Entry matrices, VertexBufferWriter writer, List<BakedQuad> quads, ItemStack itemStack, ItemColorProvider colorProvider, int light, int overlay) {
for (int i = 0; i < quads.size(); i++) {
BakedQuad bakedQuad = quads.get(i);

if (bakedQuad.getVertexData().length < 32) {
continue; // ignore bad quads
}

BakedQuadView quad = (BakedQuadView) bakedQuad;

int color = 0xFFFFFFFF;
Expand Down

0 comments on commit 42bb21e

Please sign in to comment.