From 412768c57e2e8db1c1c56be3d61ebe73c9eed161 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Mon, 23 Dec 2024 09:06:17 +1000 Subject: [PATCH] Wip on node removal support on child existence change --- .../rendering/hierachical2/NodeManager2.java | 109 ++++++++---------- 1 file changed, 46 insertions(+), 63 deletions(-) diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/hierachical2/NodeManager2.java b/src/main/java/me/cortex/voxy/client/core/rendering/hierachical2/NodeManager2.java index 37847ae5..52211bf2 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/hierachical2/NodeManager2.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/hierachical2/NodeManager2.java @@ -218,6 +218,7 @@ public class NodeManager2 { } //================================================================================================================== + //TODO: cleanup this code shitshow and extract common operations to reduce code duplication public void processChildChange(long pos, byte childExistence) { int nodeId = this.activeSectionMap.get(pos); if (nodeId == -1) { @@ -310,68 +311,13 @@ public class NodeManager2 { } private void updateChildSectionsInner(long pos, int nodeId, byte childExistence) { - //Very complex and painful operation - /** - if (this.nodeData.isNodeRequestInFlight(nodeId&NODE_ID_MSK)) { - 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"); - byte oldMsk = request.getMsk(); - byte change = (byte) (oldMsk ^ childExistence); - - -// {//Remove children that no longer exist, TODO: FIXME: THEY MIGHT NOT BE IN THE REQUEST -// byte rem = (byte) (change&childExistence); -// for (int i = 0; i < 8; i++) { -// if ((rem & (1 << i)) == 0) continue; -// int meshId = request.removeAndUnRequire(i); -// if (meshId != NULL_GEOMETRY_ID && meshId != EMPTY_GEOMETRY_ID) { -// this.geometryManager.removeSection(meshId); -// } -// -// //Remove child from being watched and activeSections -// long cPos = makeChildPos(pos, i); -// if (this.activeSectionMap.remove(cPos) == -1) {//TODO: verify the removed section is a request type of child and the request id matches this -// throw new IllegalStateException("Child pos was in a request but not in active section map"); -// } -// if (!this.updateRouter.unwatch(cPos, WorldEngine.UPDATE_FLAGS)) { -// throw new IllegalStateException("Child pos was not being watched"); -// } -// -// -// throw new IllegalStateException("UNFINISHED!: need to recursivly remove children"); -// } -// } - - - {//Add new children - byte add = (byte) (change&childExistence); - for (int i = 0; i < 8; i++) { - if ((add&(1<