aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/makamys
diff options
context:
space:
mode:
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;
}