aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys/neodymium/renderer/ChunkMesh.java
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2023-03-29 21:53:52 +0200
committermakamys <makamys@outlook.com>2023-03-29 21:57:01 +0200
commit0fb0f8427844e813bb4b09b7b845dca94e22fd46 (patch)
tree8ca4146fda54d6c39056e6ff31a203878c4fd4e2 /src/main/java/makamys/neodymium/renderer/ChunkMesh.java
parentb2c80a5f304df2e45f69f21042940c00f2220df9 (diff)
downloadNeodymium-0fb0f8427844e813bb4b09b7b845dca94e22fd46.tar.gz
Neodymium-0fb0f8427844e813bb4b09b7b845dca94e22fd46.tar.bz2
Neodymium-0fb0f8427844e813bb4b09b7b845dca94e22fd46.zip
Ignore 0 area quads (fixes #15)
Diffstat (limited to 'src/main/java/makamys/neodymium/renderer/ChunkMesh.java')
-rw-r--r--src/main/java/makamys/neodymium/renderer/ChunkMesh.java46
1 files changed, 27 insertions, 19 deletions
diff --git a/src/main/java/makamys/neodymium/renderer/ChunkMesh.java b/src/main/java/makamys/neodymium/renderer/ChunkMesh.java
index 03b93fe..c9d5839 100644
--- a/src/main/java/makamys/neodymium/renderer/ChunkMesh.java
+++ b/src/main/java/makamys/neodymium/renderer/ChunkMesh.java
@@ -93,29 +93,37 @@ public class ChunkMesh extends Mesh {
if(t.hasNormals && GL11.glIsEnabled(GL11.GL_LIGHTING)) {
errors.add("Chunk uses GL lighting, this is not implemented.");
}
- if(!errors.isEmpty()) {
- if(!Config.silenceErrors) {
- try {
- // Generate a stack trace
- throw new IllegalArgumentException();
- } catch(IllegalArgumentException e) {
- LOGGER.error("Errors in chunk ({}, {}, {})", x, y, z);
- for(String error : errors) {
- LOGGER.error("Error: " + error);
- }
- LOGGER.error("(World renderer pos: ({}, {}, {}), Tessellator pos: ({}, {}, {}), Tessellation count: {}", wr.posX, wr.posY, wr.posZ, t.xOffset, t.yOffset, t.zOffset, tesselatorDataCount);
- LOGGER.error("Stack trace:");
- e.printStackTrace();
- LOGGER.error("Skipping chunk due to errors.");
- }
- }
- return;
- }
int verticesPerPrimitive = t.drawMode == GL11.GL_QUADS ? 4 : 3;
for(int quadI = 0; quadI < t.vertexCount / verticesPerPrimitive; quadI++) {
- quadBuf.next().setState(t.rawBuffer, quadI * (verticesPerPrimitive * 8), FLAGS, t.drawMode, (float)-t.xOffset, (float)-t.yOffset, (float)-t.zOffset);
+ MeshQuad quad = quadBuf.next();
+ quad.setState(t.rawBuffer, quadI * (verticesPerPrimitive * 8), FLAGS, t.drawMode, (float)-t.xOffset, (float)-t.yOffset, (float)-t.zOffset);
+ if(quad.deleted) {
+ quadBuf.remove();
+ }
+ }
+
+ if(!quadBuf.isEmpty()) {
+ // Only show errors if we're actually supposed to be drawing something
+ if(!errors.isEmpty()) {
+ if(!Config.silenceErrors) {
+ try {
+ // Generate a stack trace
+ throw new IllegalArgumentException();
+ } catch(IllegalArgumentException e) {
+ LOGGER.error("Errors in chunk ({}, {}, {})", x, y, z);
+ for(String error : errors) {
+ LOGGER.error("Error: " + error);
+ }
+ LOGGER.error("(World renderer pos: ({}, {}, {}), Tessellator pos: ({}, {}, {}), Tessellation count: {}", wr.posX, wr.posY, wr.posZ, t.xOffset, t.yOffset, t.zOffset, tesselatorDataCount);
+ LOGGER.error("Stack trace:");
+ e.printStackTrace();
+ LOGGER.error("Skipping chunk due to errors.");
+ }
+ }
+ return;
+ }
}
}