From da7b632240e85f44964dca25510c1a33877b870b Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Thu, 22 Feb 2024 09:59:01 +1000 Subject: [PATCH] Boop --- .../config/VoxyConfigScreenFactory.java | 10 +- .../core/rendering/util/UploadStream.java | 2 + .../util/QuadTreeClosestPositionFinder.java | 92 +++++++++++++++++++ 3 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 src/main/java/me/cortex/voxy/client/terrain/util/QuadTreeClosestPositionFinder.java diff --git a/src/main/java/me/cortex/voxy/client/config/VoxyConfigScreenFactory.java b/src/main/java/me/cortex/voxy/client/config/VoxyConfigScreenFactory.java index ab60f9fc..e2b5077e 100644 --- a/src/main/java/me/cortex/voxy/client/config/VoxyConfigScreenFactory.java +++ b/src/main/java/me/cortex/voxy/client/config/VoxyConfigScreenFactory.java @@ -91,11 +91,11 @@ public class VoxyConfigScreenFactory implements ModMenuApi { .setDefaultValue(DEFAULT.maxSections) .build()); - category.addEntry(entryBuilder.startIntSlider(Text.translatable("voxy.config.general.renderDistance"), config.maxSections, 16, 2048) - .setTooltip(Text.translatable("voxy.config.general.renderDistance.tooltip")) - .setSaveConsumer(val -> config.renderDistance = val) - .setDefaultValue(DEFAULT.renderDistance) - .build()); + //category.addEntry(entryBuilder.startIntSlider(Text.translatable("voxy.config.general.renderDistance"), config.maxSections, 16, 2048) + // .setTooltip(Text.translatable("voxy.config.general.renderDistance.tooltip")) + // .setSaveConsumer(val -> config.renderDistance = val) + // .setDefaultValue(DEFAULT.renderDistance) + // .build()); //category.addEntry(entryBuilder.startIntSlider(Text.translatable("voxy.config.general.compression"), config.savingCompressionLevel, 1, 21) // .setTooltip(Text.translatable("voxy.config.general.compression.tooltip")) diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/util/UploadStream.java b/src/main/java/me/cortex/voxy/client/core/rendering/util/UploadStream.java index 2a7f48da..5c6eaffc 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/util/UploadStream.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/util/UploadStream.java @@ -14,6 +14,7 @@ import static org.lwjgl.opengl.ARBDirectStateAccess.glCopyNamedBufferSubData; import static org.lwjgl.opengl.ARBDirectStateAccess.glFlushMappedNamedBufferRange; import static org.lwjgl.opengl.ARBMapBufferRange.*; import static org.lwjgl.opengl.GL11.glFinish; +import static org.lwjgl.opengl.GL42.GL_ALL_BARRIER_BITS; import static org.lwjgl.opengl.GL42.glMemoryBarrier; import static org.lwjgl.opengl.GL42C.GL_BUFFER_UPDATE_BARRIER_BIT; import static org.lwjgl.opengl.GL43.GL_SHADER_STORAGE_BARRIER_BIT; @@ -86,6 +87,7 @@ public class UploadStream { this.flushList.clear(); } glMemoryBarrier(GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT | GL_BUFFER_UPDATE_BARRIER_BIT); + glMemoryBarrier(GL_ALL_BARRIER_BITS); //Execute all the copies for (var entry : this.uploadList) { diff --git a/src/main/java/me/cortex/voxy/client/terrain/util/QuadTreeClosestPositionFinder.java b/src/main/java/me/cortex/voxy/client/terrain/util/QuadTreeClosestPositionFinder.java new file mode 100644 index 00000000..41cc9096 --- /dev/null +++ b/src/main/java/me/cortex/voxy/client/terrain/util/QuadTreeClosestPositionFinder.java @@ -0,0 +1,92 @@ +package me.cortex.voxy.client.terrain.util; + +public class QuadTreeClosestPositionFinder { + public QuadTreeClosestPositionFinder() { + + } + + private static abstract class Node { + + } + + /* + private static class InnerNode extends Node { + private final long[] nodes = new long[1+8*8+8*8*8*8]; + private final Node[] children = new Node[8*8*8*8*8*8]; + private long getClosestPoint(long nodePos, int cx, int cz) { + long node = -1;//this.nodes[]; + if (node == -1) { + return -1; + } + float metric = Float.MAX_VALUE; + int pos = 0; + while (node != -1) { + int id = Long.numberOfTrailingZeros(node); + node &= ~(1L << id); + int x = id & 7; + int y = (id >> 3) & 7; + + } + return -1; + } + }*/ + + + /* + private static class PartialNode extends Node { + private long fullMSK; + private final Node[] children = new Node[8*8]; + private final int lvl; + + private PartialNode(int lvl) { + this.lvl = lvl; + } + + private long getClosestPoint(int[] cacheArray, int cx, int cz) { + long node = this.fullMSK; + int minDist = Integer.MAX_VALUE; + int pointCounter = 0; + while (node != -1) { + int id = Long.numberOfTrailingZeros(node); + node &= ~(1L << id); + int x = id & 7; + int z = (id >> 3) & 7; + + int dx = Math.abs(x - (cx >> this.lvl)); + int dz = Math.abs(z - (cz >> this.lvl)); + int dist = Math.max(dx, dz); + if (dist < minDist) { + pointCounter = 0; + minDist = dist; + } + if (dist == minDist) { + cacheArray[pointCounter++] = id; + } + } + + + return -1; + } + }*/ + /* + private static class InnerNode extends Node { + private final Node[] nodes = new Node[4]; + private final int lvl; + + private static final int[] ORDERING = new int[]{ + 0b00_01_10_11, + 0b01_00_11_10, + 0b10_00_11_01, + 0b11_01_10_00, + }; + + private InnerNode(int lvl) { + this.lvl = lvl; + } + + public long getClosestEmpty(long cMin, int cx, int cz) { + int id = (((cz>>this.lvl)&1)<<1) | ((cx>>this.lvl)&1); + int ordering = ORDERING[id]; + } + }*/ +}