diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/ChunkMesh.java | 39 | ||||
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/MeshQuad.java | 12 | ||||
-rw-r--r-- | src/main/java/makamys/neodymium/util/Util.java | 4 |
3 files changed, 39 insertions, 16 deletions
diff --git a/src/main/java/makamys/neodymium/renderer/ChunkMesh.java b/src/main/java/makamys/neodymium/renderer/ChunkMesh.java index b48d1dc..ea2d637 100644 --- a/src/main/java/makamys/neodymium/renderer/ChunkMesh.java +++ b/src/main/java/makamys/neodymium/renderer/ChunkMesh.java @@ -84,15 +84,24 @@ public class ChunkMesh extends Mesh { return; } List<String> errors = new ArrayList<>(); + List<String> warnings = new ArrayList<>(); if(t.drawMode != GL11.GL_QUADS && t.drawMode != GL11.GL_TRIANGLES) { errors.add("Unsupported draw mode: " + t.drawMode); } - if(!t.hasTexture || !t.hasBrightness || !t.hasColor) { - errors.add(String.format("Unsupported tessellator flags: (hasTexture=%b, hasBrightness=%b, hasColor=%b)", t.hasTexture, t.hasBrightness, t.hasColor)); + if(!t.hasTexture) { + errors.add(String.format("Texture data is missing.")); + } + if(!t.hasBrightness) { + warnings.add("Brightness data is missing"); + } + if(!t.hasColor) { + warnings.add("Color data is missing"); } if(t.hasNormals && GL11.glIsEnabled(GL11.GL_LIGHTING)) { errors.add("Chunk uses GL lighting, this is not implemented."); } + FLAGS.hasBrightness = t.hasBrightness; + FLAGS.hasColor = t.hasColor; int verticesPerPrimitive = t.drawMode == GL11.GL_QUADS ? 4 : 3; @@ -106,24 +115,30 @@ public class ChunkMesh extends Mesh { if(!quadBuf.isEmpty()) { // Only show errors if we're actually supposed to be drawing something - if(!errors.isEmpty()) { + if(!errors.isEmpty() || !warnings.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); + if(!errors.isEmpty()) { + LOGGER.error("Errors in chunk ({}, {}, {})", x, y, z); + for(String error : errors) { + LOGGER.error("Error: " + error); + } + for(String warning : warnings) { + LOGGER.error("Warning: " + warning); + } + 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."); + quadBuf.reset(); + } else { + LOGGER.debug("Warnings in chunk ({}, {}, {}): {}", x, y, z, String.join(", ", warnings)); } - 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."); } } - quadBuf.reset(); - return; } } } diff --git a/src/main/java/makamys/neodymium/renderer/MeshQuad.java b/src/main/java/makamys/neodymium/renderer/MeshQuad.java index 214b80d..ff2b1fc 100644 --- a/src/main/java/makamys/neodymium/renderer/MeshQuad.java +++ b/src/main/java/makamys/neodymium/renderer/MeshQuad.java @@ -10,6 +10,7 @@ import org.lwjgl.util.vector.Vector3f; import makamys.neodymium.config.Config; import makamys.neodymium.util.BufferWriter; +import makamys.neodymium.util.Util; /* * This is what a quad looks like. @@ -28,6 +29,9 @@ import makamys.neodymium.util.BufferWriter; */ public class MeshQuad { + private final static int DEFAULT_BRIGHTNESS = Util.createBrightness(15, 15); + private final static int DEFAULT_COLOR = 0xFFFFFFFF; + public float[] xs = new float[4]; public float[] ys = new float[4]; public float[] zs = new float[4]; @@ -67,7 +71,7 @@ public class MeshQuad { private static Vector3f vectorB = new Vector3f(); private static Vector3f vectorC = new Vector3f(); - private void read(int[] rawBuffer, int offset, float offsetX, float offsetY, float offsetZ, int drawMode) { + private void read(int[] rawBuffer, int offset, float offsetX, float offsetY, float offsetZ, int drawMode, ChunkMesh.Flags flags) { int vertices = drawMode == GL11.GL_TRIANGLES ? 3 : 4; for(int vi = 0; vi < vertices; vi++) { int i = offset + vi * 8; @@ -79,8 +83,8 @@ public class MeshQuad { us[vi] = Float.intBitsToFloat(rawBuffer[i + 3]); vs[vi] = Float.intBitsToFloat(rawBuffer[i + 4]); - bs[vi] = rawBuffer[i + 7]; - cs[vi] = rawBuffer[i + 5]; + bs[vi] = flags.hasBrightness ? rawBuffer[i + 7] : DEFAULT_BRIGHTNESS; + cs[vi] = flags.hasColor ? rawBuffer[i + 5] : DEFAULT_COLOR; i += 8; } @@ -102,7 +106,7 @@ public class MeshQuad { public void setState(int[] rawBuffer, int offset, ChunkMesh.Flags flags, int drawMode, float offsetX, float offsetY, float offsetZ) { resetState(); - read(rawBuffer, offset, offsetX, offsetY, offsetZ, drawMode); + read(rawBuffer, offset, offsetX, offsetY, offsetZ, drawMode, flags); 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) diff --git a/src/main/java/makamys/neodymium/util/Util.java b/src/main/java/makamys/neodymium/util/Util.java index 89ab1ea..cd43358 100644 --- a/src/main/java/makamys/neodymium/util/Util.java +++ b/src/main/java/makamys/neodymium/util/Util.java @@ -106,4 +106,8 @@ public class Util { e.printStackTrace(); } } + + public static int createBrightness(int sky, int block) { + return sky << 20 | block << 4; + } } |