From ed0bd1a2b5e6795c6d72e59181804bc8d308c35d Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Sun, 5 Jan 2025 02:13:11 +1000 Subject: [PATCH] Ref B --- .../rendering/hierarchical/NodeManager.java | 1 - .../core/util/MarkedCachedObjectList.java | 51 ------------------- .../voxy/client/importers/WorldImporter.java | 3 +- .../minecraft/MixinClientChunkManager.java | 31 ----------- .../mixin/nvidium/MixinRenderPipeline.java | 27 ---------- .../util/ByteBufferBackedInputStream.java | 2 +- src/main/resources/client.voxy.mixins.json | 1 - 7 files changed, 2 insertions(+), 114 deletions(-) delete mode 100644 src/main/java/me/cortex/voxy/client/core/util/MarkedCachedObjectList.java delete mode 100644 src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinClientChunkManager.java delete mode 100644 src/main/java/me/cortex/voxy/client/mixin/nvidium/MixinRenderPipeline.java rename src/main/java/me/cortex/voxy/{client/core => common}/util/ByteBufferBackedInputStream.java (94%) diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/hierarchical/NodeManager.java b/src/main/java/me/cortex/voxy/client/core/rendering/hierarchical/NodeManager.java index 860bef82..1266f647 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/hierarchical/NodeManager.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/hierarchical/NodeManager.java @@ -6,7 +6,6 @@ import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import me.cortex.voxy.client.core.gl.GlBuffer; import me.cortex.voxy.client.core.rendering.building.BuiltSection; import me.cortex.voxy.client.core.rendering.util.DownloadStream; -import me.cortex.voxy.client.core.util.MarkedCachedObjectList; import me.cortex.voxy.client.core.rendering.util.UploadStream; import me.cortex.voxy.common.util.HierarchicalBitSet; import me.cortex.voxy.common.world.WorldEngine; diff --git a/src/main/java/me/cortex/voxy/client/core/util/MarkedCachedObjectList.java b/src/main/java/me/cortex/voxy/client/core/util/MarkedCachedObjectList.java deleted file mode 100644 index ce4a336b..00000000 --- a/src/main/java/me/cortex/voxy/client/core/util/MarkedCachedObjectList.java +++ /dev/null @@ -1,51 +0,0 @@ -package me.cortex.voxy.client.core.util; - -import it.unimi.dsi.fastutil.ints.Int2ObjectFunction; -import me.cortex.voxy.common.util.HierarchicalBitSet; - -import java.util.function.Supplier; - -public class MarkedCachedObjectList { - private static final float GROWTH_FACTOR = 0.75f; - - private final Int2ObjectFunction arrayGenerator; - private final Supplier nullSupplier; - private final HierarchicalBitSet bitSet = new HierarchicalBitSet(); - private T[] objects;//Should maybe make a getter function instead - - public MarkedCachedObjectList(Int2ObjectFunction arrayGenerator, Supplier nullSupplier) { - this.arrayGenerator = arrayGenerator; - this.nullSupplier = nullSupplier; - this.objects = this.arrayGenerator.apply(16); - } - - public int allocate() { - //Gets an unused id for some entry in objects, if its null fill it - int id = this.bitSet.allocateNext(); - if (this.objects.length <= id) { - //Resize and copy over the objects array - int newLen = this.objects.length + (int)Math.ceil(this.objects.length*GROWTH_FACTOR); - T[] newArr = this.arrayGenerator.apply(newLen); - System.arraycopy(this.objects, 0, newArr, 0, this.objects.length); - this.objects = newArr; - } - if (this.objects[id] == null) { - this.objects[id] = this.nullSupplier.get(); - } - return id; - } - - public void release(int id) { - if (!this.bitSet.free(id)) { - throw new IllegalArgumentException("Index " + id + " was already released"); - } - } - - public T get(int index) { - //Make the checking that index is allocated optional, as it might cause overhead due to multiple cacheline misses - if (!this.bitSet.isSet(index)) { - throw new IllegalArgumentException("Index " + index + " is not allocated"); - } - return this.objects[index]; - } -} diff --git a/src/main/java/me/cortex/voxy/client/importers/WorldImporter.java b/src/main/java/me/cortex/voxy/client/importers/WorldImporter.java index a15ca8db..1cfd8d47 100644 --- a/src/main/java/me/cortex/voxy/client/importers/WorldImporter.java +++ b/src/main/java/me/cortex/voxy/client/importers/WorldImporter.java @@ -1,7 +1,7 @@ package me.cortex.voxy.client.importers; import com.mojang.serialization.Codec; -import me.cortex.voxy.client.core.util.ByteBufferBackedInputStream; +import me.cortex.voxy.common.util.ByteBufferBackedInputStream; import me.cortex.voxy.common.Logger; import me.cortex.voxy.common.voxelization.VoxelizedSection; import me.cortex.voxy.common.voxelization.WorldConversionFactory; @@ -32,7 +32,6 @@ import java.nio.channels.FileChannel; import java.nio.file.Path; import java.nio.file.StandardOpenOption; import java.util.Arrays; -import java.util.Collection; import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; diff --git a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinClientChunkManager.java b/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinClientChunkManager.java deleted file mode 100644 index 5dfb0624..00000000 --- a/src/main/java/me/cortex/voxy/client/mixin/minecraft/MixinClientChunkManager.java +++ /dev/null @@ -1,31 +0,0 @@ -package me.cortex.voxy.client.mixin.minecraft; - -import me.cortex.voxy.client.config.VoxyConfig; -import me.cortex.voxy.client.core.IGetVoxelCore; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.world.ClientChunkManager; -import net.minecraft.client.world.ClientWorld; -import net.minecraft.util.math.ChunkPos; -import net.minecraft.world.chunk.WorldChunk; -import org.spongepowered.asm.mixin.Final; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -/* -@Mixin(ClientChunkManager.class) -public class MixinClientChunkManager { - @Shadow @Final ClientWorld world; - - @Inject(require = 0, method = "unload", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/world/ClientChunkManager$ClientChunkMap;compareAndSet(ILnet/minecraft/world/chunk/WorldChunk;Lnet/minecraft/world/chunk/WorldChunk;)Lnet/minecraft/world/chunk/WorldChunk;", shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD) - private void injectUnload(ChunkPos pos, CallbackInfo ci, int index, WorldChunk worldChunk) { - var core = ((IGetVoxelCore)(world.worldRenderer)).getVoxelCore(); - if (core != null && VoxyConfig.CONFIG.ingestEnabled) { - //core.enqueueIngest(worldChunk); - } - } -} -*/ \ No newline at end of file diff --git a/src/main/java/me/cortex/voxy/client/mixin/nvidium/MixinRenderPipeline.java b/src/main/java/me/cortex/voxy/client/mixin/nvidium/MixinRenderPipeline.java deleted file mode 100644 index 0b4c8e27..00000000 --- a/src/main/java/me/cortex/voxy/client/mixin/nvidium/MixinRenderPipeline.java +++ /dev/null @@ -1,27 +0,0 @@ -package me.cortex.voxy.client.mixin.nvidium; - -import me.cortex.nvidium.RenderPipeline; -import me.cortex.voxy.client.config.VoxyConfig; -import me.cortex.voxy.client.core.IGetVoxelCore; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.util.math.MatrixStack; -import org.joml.Matrix4f; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(value = RenderPipeline.class, remap = false) -public class MixinRenderPipeline { - /* - @Inject(method = "renderFrame", at = @At("RETURN")) - private void injectVoxyRender(Viewport frustum, ChunkRenderMatrices crm, double px, double py, double pz, CallbackInfo ci) { - var core = ((IGetVoxelCore) MinecraftClient.getInstance().worldRenderer).getVoxelCore(); - if (core != null) { - var stack = new MatrixStack(); - stack.loadIdentity(); - stack.multiplyPositionMatrix(new Matrix4f(crm.modelView())); - core.renderOpaque(stack, px, py, pz); - } - }*/ -} diff --git a/src/main/java/me/cortex/voxy/client/core/util/ByteBufferBackedInputStream.java b/src/main/java/me/cortex/voxy/common/util/ByteBufferBackedInputStream.java similarity index 94% rename from src/main/java/me/cortex/voxy/client/core/util/ByteBufferBackedInputStream.java rename to src/main/java/me/cortex/voxy/common/util/ByteBufferBackedInputStream.java index 9502f9cc..9a3463c1 100644 --- a/src/main/java/me/cortex/voxy/client/core/util/ByteBufferBackedInputStream.java +++ b/src/main/java/me/cortex/voxy/common/util/ByteBufferBackedInputStream.java @@ -1,4 +1,4 @@ -package me.cortex.voxy.client.core.util; +package me.cortex.voxy.common.util; import java.io.IOException; import java.io.InputStream; diff --git a/src/main/resources/client.voxy.mixins.json b/src/main/resources/client.voxy.mixins.json index eb18b978..20339f53 100644 --- a/src/main/resources/client.voxy.mixins.json +++ b/src/main/resources/client.voxy.mixins.json @@ -8,7 +8,6 @@ "minecraft.MixinDebugHud", "minecraft.MixinMinecraftClient", "minecraft.MixinWorldRenderer", - "nvidium.MixinRenderPipeline", "sodium.MixinDefaultChunkRenderer", "sodium.MixinRenderSectionManager" ],