aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys
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
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')
-rw-r--r--src/main/java/makamys/neodymium/renderer/ChunkMesh.java46
-rw-r--r--src/main/java/makamys/neodymium/renderer/MeshQuad.java6
-rw-r--r--src/main/java/makamys/neodymium/util/RecyclingList.java11
3 files changed, 44 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;
+ }
}
}
diff --git a/src/main/java/makamys/neodymium/renderer/MeshQuad.java b/src/main/java/makamys/neodymium/renderer/MeshQuad.java
index 56827ee..214b80d 100644
--- a/src/main/java/makamys/neodymium/renderer/MeshQuad.java
+++ b/src/main/java/makamys/neodymium/renderer/MeshQuad.java
@@ -104,6 +104,12 @@ public class MeshQuad {
read(rawBuffer, offset, offsetX, offsetY, offsetZ, drawMode);
+ if(xs[0] == xs[1] && xs[1] == xs[2] && xs[2] == xs[3] && ys[0] == ys[1] && ys[1] == ys[2] && ys[2] == ys[3]) {
+ // ignore empty quads (e.g. alpha pass of EnderIO item conduits)
+ deleted = true;
+ return;
+ }
+
uDirectionIs01 = us[0] != us[1];
updateMinMaxXYZ();
diff --git a/src/main/java/makamys/neodymium/util/RecyclingList.java b/src/main/java/makamys/neodymium/util/RecyclingList.java
index ea240bb..488b708 100644
--- a/src/main/java/makamys/neodymium/util/RecyclingList.java
+++ b/src/main/java/makamys/neodymium/util/RecyclingList.java
@@ -27,6 +27,17 @@ public class RecyclingList<T> {
return get(nextIndex++);
}
+ public void remove() {
+ if(nextIndex == 0) {
+ throw new IllegalStateException("Tried to remove from empty list");
+ }
+ nextIndex--;
+ }
+
+ public boolean isEmpty() {
+ return nextIndex == 0;
+ }
+
public void reset() {
nextIndex = 0;
}