From 325983152a0d7fc23174bcaf7837027b17787312 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Sat, 19 Apr 2025 11:00:46 +1000 Subject: [PATCH] more testing stuff --- .../rendering/hierachical/NodeManager.java | 32 ++++++++++++++++++- .../hierachical/TestNodeManager.java | 32 ++++++++++++++++--- 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/NodeManager.java b/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/NodeManager.java index 08d81cb1..004f6064 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/NodeManager.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/NodeManager.java @@ -801,7 +801,9 @@ public class NodeManager { //Assume that this is always a top node // FIXME: DONT DO THIS - this.topLevelNodeIds.add(id); + if (!this.topLevelNodeIds.add(id)) { + throw new IllegalStateException(); + } this.clearAllocId(id); } @@ -1042,6 +1044,12 @@ public class NodeManager { throw new IllegalStateException("Unknown node type: " + nodeType); } + + if (WorldEngine.getLevel(pos) == 0) { + Logger.error("Requests cannot exist for bottom level nodes. at: " + WorldEngine.pprintPos(pos) + ". Ignoring request"); + return; + } + //TODO: ADJUST AND FIX THIS TO MAKE IT REMOVE THE LAST THING IN QUEUE OR SOMETHING //if (this.activeNodeRequestCount > 100 && WorldEngine.getLevel(pos) < 2) { //Logger.info("Many active requests, declining request at " + WorldEngine.pprintPos(pos)); @@ -1070,6 +1078,7 @@ public class NodeManager { // in this case we should not mark the node as inflight as it casuse very bad things to happen // we should only mark inflight when there is actually a request if (nodeType == NODE_TYPE_LEAF) { + if (this.nodeData.getNodeGeometry(nodeId) == NULL_GEOMETRY_ID) { //Weird case that not sure how possible Logger.warn("Got request for leaf that doesnt have geometry, this should not be possible at pos " + WorldEngine.pprintPos(pos)); @@ -1632,5 +1641,26 @@ public class NodeManager { throw new IllegalStateException(); } } + + IntSet tln = new IntOpenHashSet(this.topLevelNodeIds.size()); + for (long p : this.topLevelNodes) { + int n = this.activeSectionMap.get(p); + if (n == -1) { + throw new IllegalStateException(); + } + if ((n&NODE_TYPE_MSK)!=NODE_TYPE_REQUEST) { + if (!tln.add(n&NODE_ID_MSK)) { + throw new IllegalStateException(); + } + } + } + + if (!this.topLevelNodeIds.containsAll(tln)) { + throw new IllegalStateException(); + } + + if (!tln.containsAll(this.topLevelNodeIds)) { + throw new IllegalStateException(); + } } } diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/TestNodeManager.java b/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/TestNodeManager.java index 40ee54a7..2bfcb9f5 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/TestNodeManager.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/hierachical/TestNodeManager.java @@ -312,21 +312,43 @@ public class TestNodeManager { } private static boolean runTest(int ITERS, int testIdx, Set> traces, boolean geoRemoval) { - long POS_A = WorldEngine.getWorldSectionId(4, 0, 0, 0); - Random r = new Random(testIdx * 1234L); try { var test = new TestBase(); LongList tops = new LongArrayList(); + + int R = 1; + if (r.nextBoolean()) { + R++; + if (r.nextBoolean()) { + R++; + if (r.nextBoolean()) { + R++; + } + } + } + //Fuzzy bruteforce everything - test.putTopPos(POS_A); - tops.add(POS_A); + 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 (long p : tops) { + test.putTopPos(p); + test.meshUpdate(p, -1, 18); + fillInALl(test, p, a->-1); + test.printNodeChanges(); + test.verifyIntegrity(); + } for (int i = 0; i < ITERS; i++) { long pos = rPos(r, tops); int op = r.nextInt(5); int extra = r.nextInt(256); boolean hasGeometry = r.nextBoolean(); - boolean addRemTLN = r.nextInt(512) == 0; + 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);