Add validation of top level position + MiB if path

This commit is contained in:
mcrcortex
2025-05-18 12:41:26 +10:00
parent fd22ea4153
commit 2962b47939
3 changed files with 38 additions and 8 deletions

View File

@@ -61,10 +61,18 @@ public class VoxyRenderSystem {
this.worldIn = world;
this.renderer = new RenderService(world, threadPool);
this.postProcessing = new PostProcessing();
int minSec = MinecraftClient.getInstance().world.getBottomSectionCoord()>>5;
int maxSec = (MinecraftClient.getInstance().world.getTopSectionCoord()-1)>>5;
//Do some very cheeky stuff for MiB
if (false) {
minSec = -8;
maxSec = 7;
}
this.renderDistanceTracker = new RenderDistanceTracker(20,
MinecraftClient.getInstance().world.getBottomSectionCoord()>>5,
(MinecraftClient.getInstance().world.getTopSectionCoord()-1)>>5,
minSec,
maxSec,
this.renderer::addTopLevelNode,
this.renderer::removeTopLevelNode);
@@ -160,6 +168,7 @@ public class VoxyRenderSystem {
cameraX -= sector<<14;//10+4
cameraY += (16+(256-32-sector*30))*16;
}
long startTime = System.nanoTime();
TimingStatistics.all.start();
TimingStatistics.main.start();

View File

@@ -123,7 +123,27 @@ public class NodeManager {
this.geometryManager = geometryManager;
}
private static void assertPosValid(long pos) {
int lvl = WorldEngine.getLevel(pos);
int x = WorldEngine.getX(pos);
int y = WorldEngine.getY(pos);
int z = WorldEngine.getZ(pos);
if (WorldEngine.getWorldSectionId(lvl, x, y, z) != pos) {
throw new IllegalStateException("Reconstructed pos not same as original");
}
x <<= lvl;
y <<= lvl;
z <<= lvl;
long p2 = WorldEngine.getWorldSectionId(0, x, y, z);
if (WorldEngine.getLevel(p2) != 0 || WorldEngine.getX(p2) != x || WorldEngine.getY(p2) != y || WorldEngine.getZ(p2) != z) {
throw new IllegalStateException("Position not valid at all levels");
}
}
public void insertTopLevelNode(long pos) {
//Verify that pos is actually valid
assertPosValid(pos);
if ((pos&0xF) != 0) {
throw new IllegalStateException("BAD POS !! YOU DID SOMETHING VERY BAD");
}
@@ -399,7 +419,7 @@ public class NodeManager {
// so add the new nodes to it
int requestId = this.nodeData.getNodeRequest(nodeId);
var request = this.childRequests.get(requestId);// TODO: do not assume request is childRequest (it will probably always be)
if (request.getPosition() != pos) throw new IllegalStateException("Request is not at pos");
if (request.getPosition() != pos) throw new IllegalStateException("Request is not at pos: got " + WorldEngine.pprintPos(pos) + " expected: " + WorldEngine.pprintPos(request.getPosition()));
//Add all new children to the request
for (int i = 0; i < 8; i++) {

View File

@@ -277,7 +277,7 @@ public class TestNodeManager {
public static void main(String[] args) {
Logger.INSERT_CLASS = false;
int ITER_COUNT = 5_000;
int INNER_ITER_COUNT = 100_000;
int INNER_ITER_COUNT = 1_000_000;
boolean GEO_REM = true;
AtomicInteger finished = new AtomicInteger();
@@ -285,7 +285,7 @@ public class TestNodeManager {
Logger.SHUTUP = true;
if (false) {
if (true) {
for (int q = 0; q < ITER_COUNT; q++) {
//Logger.info("Iteration "+ q);
if (runTest(INNER_ITER_COUNT, q, seenTraces, GEO_REM)) {
@@ -331,8 +331,9 @@ public class TestNodeManager {
//Fuzzy bruteforce everything
for (int x = -R; x<=R; x++) {
for (int z = -R; z<=R; z++) {
tops.add(WorldEngine.getWorldSectionId(4, x, 0, z));
tops.add(WorldEngine.getWorldSectionId(4, x, 1, z));
for (int y = -8; y<=7; y++) {
tops.add(WorldEngine.getWorldSectionId(4, x, y, z));
}
}
}
@@ -351,7 +352,7 @@ public class TestNodeManager {
boolean addRemTLN = r.nextInt(64) == 0;
boolean extraBool = r.nextBoolean();
if (op == 0 && addRemTLN) {
pos = WorldEngine.getWorldSectionId(4, r.nextInt(5)-2, r.nextInt(5)-2, r.nextInt(5)-2);
pos = WorldEngine.getWorldSectionId(4, r.nextInt(5)-2, r.nextInt(32)-16, r.nextInt(5)-2);
boolean cont = tops.contains(pos);
if (cont&&extraBool&&tops.size()>1) {
extraBool = true;