more occupancy

This commit is contained in:
mcrcortex
2025-12-23 10:42:17 +10:00
parent 61da430895
commit 1e7b199660
2 changed files with 15 additions and 4 deletions

View File

@@ -13,9 +13,10 @@ public final class BuiltSection {
public final int aabb; public final int aabb;
public final MemoryBuffer geometryBuffer; public final MemoryBuffer geometryBuffer;
public final int[] offsets; public final int[] offsets;
public final MemoryBuffer occupancy;
private BuiltSection(long position, byte children) { 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) { public static BuiltSection empty(long position) {
@@ -25,7 +26,7 @@ public final class BuiltSection {
return new BuiltSection(position, children); 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.position = position;
this.childExistence = childExistence; this.childExistence = childExistence;
this.aabb = aabb; this.aabb = aabb;
@@ -39,16 +40,20 @@ public final class BuiltSection {
} }
} }
} }
this.occupancy = occupancy;
} }
public BuiltSection clone() { 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() { public void free() {
if (this.geometryBuffer != null) { if (this.geometryBuffer != null) {
this.geometryBuffer.free(); this.geometryBuffer.free();
} }
if (this.occupancy != null) {
this.occupancy.free();
}
} }
public boolean isEmpty() { public boolean isEmpty() {

View File

@@ -1698,7 +1698,13 @@ public class RenderDataFactory {
aabb |= (this.maxY-this.minY-1)<<20; aabb |= (this.maxY-this.minY-1)<<20;
aabb |= (this.maxZ-this.minZ-1)<<25; 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() { public void free() {