From 1e7b199660a3f8a683ee4078e012738ab436b354 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Tue, 23 Dec 2025 10:42:17 +1000 Subject: [PATCH] more occupancy --- .../client/core/rendering/building/BuiltSection.java | 11 ++++++++--- .../core/rendering/building/RenderDataFactory.java | 8 +++++++- 2 files changed, 15 insertions(+), 4 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 64e3e035..4032ce0a 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 @@ -13,9 +13,10 @@ public final class BuiltSection { public final int aabb; public final MemoryBuffer geometryBuffer; public final int[] offsets; + public final MemoryBuffer occupancy; private BuiltSection(long position, byte children) { - this(position, children, -1, null, null); + this(position, children, -1, null, null, null); } public static BuiltSection empty(long position) { @@ -25,7 +26,7 @@ public final class BuiltSection { return new BuiltSection(position, children); } - public BuiltSection(long position, byte childExistence, int aabb, MemoryBuffer geometryBuffer, int[] offsets) { + public BuiltSection(long position, byte childExistence, int aabb, MemoryBuffer geometryBuffer, int[] offsets, MemoryBuffer occupancy) { this.position = position; this.childExistence = childExistence; this.aabb = aabb; @@ -39,16 +40,20 @@ public final class BuiltSection { } } } + this.occupancy = occupancy; } public BuiltSection clone() { - return new BuiltSection(this.position, this.childExistence, this.aabb, this.geometryBuffer!=null?this.geometryBuffer.copy():null, this.offsets!=null?Arrays.copyOf(this.offsets, this.offsets.length):null); + return new BuiltSection(this.position, this.childExistence, this.aabb, this.geometryBuffer!=null?this.geometryBuffer.copy():null, this.offsets!=null?Arrays.copyOf(this.offsets, this.offsets.length):null, this.occupancy!=null?this.occupancy.copy():null); } public void free() { if (this.geometryBuffer != null) { this.geometryBuffer.free(); } + if (this.occupancy != null) { + this.occupancy.free(); + } } public boolean isEmpty() { diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory.java b/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory.java index 3080a2db..7375aa8e 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory.java @@ -1698,7 +1698,13 @@ public class RenderDataFactory { aabb |= (this.maxY-this.minY-1)<<20; aabb |= (this.maxZ-this.minZ-1)<<25; - return new BuiltSection(section.key, section.getNonEmptyChildren(), aabb, buff, offsets); + MemoryBuffer occupancy = null; + if (BUILD_OCCUPANCY_SET && !this.occupancy.isEmpty()) { + occupancy = new MemoryBuffer(this.occupancy.writeSize()); + this.occupancy.write(occupancy.address, false); + } + + return new BuiltSection(section.key, section.getNonEmptyChildren(), aabb, buff, offsets, occupancy); } public void free() {