From d9fc4b3c058fc9efbd6f27876e9518fda8fc2c04 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Thu, 5 Dec 2024 19:38:45 +1000 Subject: [PATCH] Added extra state checking and fixed empty geometry not returning child existence bits, added lighting back --- .../client/core/rendering/building/BuiltSection.java | 9 ++++++--- .../core/rendering/building/RenderDataFactory4.java | 6 +++--- .../client/core/rendering/hierachical2/NodeManager2.java | 6 +++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/building/BuiltSection.java b/src/main/java/me/cortex/voxy/client/core/rendering/building/BuiltSection.java index e8df143d..64e3e035 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/building/BuiltSection.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/building/BuiltSection.java @@ -14,12 +14,15 @@ public final class BuiltSection { public final MemoryBuffer geometryBuffer; public final int[] offsets; - private BuiltSection(long position) { - this(position, (byte) 0, -1, null, null); + private BuiltSection(long position, byte children) { + this(position, children, -1, null, null); } public static BuiltSection empty(long position) { - return new BuiltSection(position); + return new BuiltSection(position, (byte) 0); + } + public static BuiltSection emptyWithChildren(long position, byte children) { + return new BuiltSection(position, children); } public BuiltSection(long position, byte childExistence, int aabb, MemoryBuffer geometryBuffer, int[] offsets) { diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory4.java b/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory4.java index 422b3941..f223e91a 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory4.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory4.java @@ -210,7 +210,7 @@ public class RenderDataFactory4 { long nextModel = facingForward == 1 ? B : A; //Example thing thats just wrong but as example - this.blockMesher.putNext((long) facingForward | ((selfModel & 0xFFFF) << 26) | (0xFFL << 55)); + this.blockMesher.putNext((long) facingForward | ((selfModel & 0xFFFF) << 26) | (((nextModel>>16)&0xFF) << 55)); } } this.blockMesher.endRow(); @@ -319,7 +319,7 @@ public class RenderDataFactory4 { long nextModel = facingForward==1?B:A; //Example thing thats just wrong but as example - mesher.putNext((long) facingForward | ((selfModel&0xFFFF)<<26) | (0xFFL<<55)); + mesher.putNext((long) facingForward | ((selfModel&0xFFFF)<<26) | (((nextModel>>16)&0xFF)<<55)); //mesher.emitQuad(y, z, 1, 1,(long) facingForward | ((selfModel&0xFFFF)<<26) | (0xFFL<<55)); } } @@ -399,7 +399,7 @@ public class RenderDataFactory4 { // this stops e.g. multiple layers of glass (and ocean) from having 3000 layers of quads etc if (this.quadCount == 0) { - return BuiltSection.empty(section.key); + return BuiltSection.emptyWithChildren(section.key, section.getNonEmptyChildren()); } //TODO: FIXME AND OPTIMIZE, get rid of the stupid quad collector bullshit diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/hierachical2/NodeManager2.java b/src/main/java/me/cortex/voxy/client/core/rendering/hierachical2/NodeManager2.java index 8502f071..c4f256c3 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/hierachical2/NodeManager2.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/hierachical2/NodeManager2.java @@ -280,7 +280,11 @@ public class NodeManager2 { int childNodeId = base+offset; //Fill in node this.nodeData.setNodePosition(childNodeId, childPos); - this.nodeData.setNodeChildExistence(childNodeId, request.getChildChildExistence(childIdx)); + byte childExistence = request.getChildChildExistence(childIdx); + if (childExistence == 0) { + throw new IllegalStateException("Request result with child existence of 0"); + } + this.nodeData.setNodeChildExistence(childNodeId, childExistence); this.nodeData.setNodeGeometry(childNodeId, request.getChildMesh(childIdx)); //Mark for update this.invalidateNode(childNodeId);