Skip to content

Commit 4fbd785

Browse files
committed
Catch exception when a model defines a collapsed face. Fixes #43
1 parent 4c65c47 commit 4fbd785

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

BlueMapCore/src/main/java/de/bluecolored/bluemap/core/render/hires/blockmodel/ResourceModelBuilder.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,17 @@ private void createElementFace(BlockStateModel model, TransformedBlockModelResou
189189
Texture texture = face.getTexture();
190190
int textureId = texture.getId();
191191

192-
ExtendedFace f1 = new ExtendedFace(c0, c1, c2, uvs[0], uvs[1], uvs[2], textureId);
193-
ExtendedFace f2 = new ExtendedFace(c0, c2, c3, uvs[0], uvs[2], uvs[3], textureId);
192+
ExtendedFace f1;
193+
ExtendedFace f2;
194+
195+
try {
196+
f1 = new ExtendedFace(c0, c1, c2, uvs[0], uvs[1], uvs[2], textureId);
197+
f2 = new ExtendedFace(c0, c2, c3, uvs[0], uvs[2], uvs[3], textureId);
198+
} catch (ArithmeticException ex) {
199+
// This error is thrown when a model defined a face that has no surface (all 3 points are on one line)
200+
// we catch it here and simply ignore the face
201+
return;
202+
}
194203

195204
//tint the face
196205
Vector3f color = Vector3f.ONE;

0 commit comments

Comments
 (0)