This commit is contained in:
mcrcortex
2025-01-05 02:13:11 +10:00
parent 7def1b487c
commit ed0bd1a2b5
7 changed files with 2 additions and 114 deletions

View File

@@ -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;

View File

@@ -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<T> {
private static final float GROWTH_FACTOR = 0.75f;
private final Int2ObjectFunction<T[]> arrayGenerator;
private final Supplier<T> nullSupplier;
private final HierarchicalBitSet bitSet = new HierarchicalBitSet();
private T[] objects;//Should maybe make a getter function instead
public MarkedCachedObjectList(Int2ObjectFunction<T[]> arrayGenerator, Supplier<T> 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];
}
}

View File

@@ -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;

View File

@@ -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);
}
}
}
*/

View File

@@ -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);
}
}*/
}

View File

@@ -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;

View File

@@ -8,7 +8,6 @@
"minecraft.MixinDebugHud",
"minecraft.MixinMinecraftClient",
"minecraft.MixinWorldRenderer",
"nvidium.MixinRenderPipeline",
"sodium.MixinDefaultChunkRenderer",
"sodium.MixinRenderSectionManager"
],