Another flag

This commit is contained in:
mcrcortex
2024-08-08 02:05:23 +10:00
parent fce77cbd5f
commit b81fd46929
3 changed files with 6 additions and 2 deletions

View File

@@ -6,6 +6,7 @@ import java.util.Arrays;
//TODO: also have an AABB size stored //TODO: also have an AABB size stored
public final class BuiltSection { public final class BuiltSection {
public static final boolean VERIFY_BUILT_SECTION_OFFSETS = System.getProperty("voxy.verifyBuiltSectionOffsets", "true").equals("true");
public final long position; public final long position;
public final int aabb; public final int aabb;
public final MemoryBuffer geometryBuffer; public final MemoryBuffer geometryBuffer;
@@ -20,7 +21,7 @@ public final class BuiltSection {
this.aabb = aabb; this.aabb = aabb;
this.geometryBuffer = geometryBuffer; this.geometryBuffer = geometryBuffer;
this.offsets = offsets; this.offsets = offsets;
if (offsets != null) { if (offsets != null && VERIFY_BUILT_SECTION_OFFSETS) {
for (int i = 0; i < offsets.length-1; i++) { for (int i = 0; i < offsets.length-1; i++) {
int delta = offsets[i+1] - offsets[i]; int delta = offsets[i+1] - offsets[i];
if (delta<0||delta>=(1<<16)) { if (delta<0||delta>=(1<<16)) {

View File

@@ -27,9 +27,11 @@ public class QuadEncoder {
//Note: the encodedMeshedData is from the Mesher2D //Note: the encodedMeshedData is from the Mesher2D
public static int encodePosition(int face, int otherAxis, int encodedMeshedData) { public static int encodePosition(int face, int otherAxis, int encodedMeshedData) {
/*
if (false&&(Mesher2D.getW(encodedMeshedData) > 16 || Mesher2D.getH(encodedMeshedData) > 16)) { if (false&&(Mesher2D.getW(encodedMeshedData) > 16 || Mesher2D.getH(encodedMeshedData) > 16)) {
throw new IllegalStateException("Width or height > 16"); throw new IllegalStateException("Width or height > 16");
} }
*/
int dat = face; int dat = face;
dat |= ((Mesher2D.getW(encodedMeshedData) - 1) << 7) | dat |= ((Mesher2D.getW(encodedMeshedData) - 1) << 7) |
((Mesher2D.getH(encodedMeshedData) - 1) << 3); ((Mesher2D.getH(encodedMeshedData) - 1) << 3);

View File

@@ -28,9 +28,10 @@ public final class Mesher2D {
private int getIdx(int x, int z) { private int getIdx(int x, int z) {
int M = (1<<this.size)-1; int M = (1<<this.size)-1;
/*
if (false&&(x>M || z>M)) { if (false&&(x>M || z>M)) {
throw new IllegalStateException(); throw new IllegalStateException();
} }*/
return ((z&M)<<this.size)|(x&M); return ((z&M)<<this.size)|(x&M);
} }