Remove old render factory, rename RenderDataFactory45 to just RenderDataFactory

This commit is contained in:
mcrcortex
2025-05-07 01:19:22 +10:00
parent fb52dea6fa
commit e42802a2bd
5 changed files with 1560 additions and 2164 deletions

View File

@@ -10,7 +10,7 @@ import me.cortex.voxy.client.core.model.ModelBakerySubsystem;
import me.cortex.voxy.client.core.rendering.ChunkBoundRenderer;
import me.cortex.voxy.client.core.rendering.RenderDistanceTracker;
import me.cortex.voxy.client.core.rendering.RenderService;
import me.cortex.voxy.client.core.rendering.building.RenderDataFactory45;
import me.cortex.voxy.client.core.rendering.building.RenderDataFactory;
import me.cortex.voxy.client.core.rendering.building.RenderGenerationService;
import me.cortex.voxy.client.core.rendering.post.PostProcessing;
import me.cortex.voxy.client.core.rendering.util.DownloadStream;
@@ -30,7 +30,6 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gl.GlBackend;
import net.minecraft.client.render.Camera;
import net.minecraft.client.render.Frustum;
import net.minecraft.client.util.math.MatrixStack;
import org.joml.Matrix4f;
import org.joml.Matrix4fc;
import org.lwjgl.opengl.GL11;
@@ -248,7 +247,7 @@ public class VoxyRenderSystem {
private void testMeshingPerformance() {
var modelService = new ModelBakerySubsystem(this.worldIn.getMapper());
var factory = new RenderDataFactory45(this.worldIn, modelService.factory, false);
var factory = new RenderDataFactory(this.worldIn, modelService.factory, false);
List<WorldSection> sections = new ArrayList<>();

View File

@@ -1,56 +0,0 @@
package me.cortex.voxy.client.core.rendering.building;
import me.cortex.voxy.client.core.util.Mesher2D;
public class QuadEncoder {
public static int getX(long data) {
return (int) ((data>>21)&0b11111);
}
public static int getY(long data) {
return (int) ((data>>16)&0b11111);
}
public static int getZ(long data) {
return (int) ((data>>11)&0b11111);
}
public static int getW(long data) {
return (int) ((data>>3)&0b1111)+1;
}
public static int getH(long data) {
return (int) ((data>>7)&0b1111)+1;
}
public static int getFace(long data) {
return (int) (data&0b111);
}
//Note: the encodedMeshedData is from the Mesher2D
public static int encodePosition(int face, int otherAxis, int encodedMeshedData) {
/*
if (false&&(Mesher2D.getW(encodedMeshedData) > 16 || Mesher2D.getH(encodedMeshedData) > 16)) {
throw new IllegalStateException("Width or height > 16");
}
*/
int dat = face;
dat |= ((Mesher2D.getW(encodedMeshedData) - 1) << 7) |
((Mesher2D.getH(encodedMeshedData) - 1) << 3);
if (face>>1 == 0) {
return dat |
(Mesher2D.getX(encodedMeshedData) << 21) |
(otherAxis << 16) |
(Mesher2D.getZ(encodedMeshedData) << 11);
}
if (face>>1 == 1) {
return dat |
(Mesher2D.getX(encodedMeshedData) << 21) |
(Mesher2D.getZ(encodedMeshedData) << 16) |
(otherAxis << 11);
}
return dat |
(otherAxis << 21) |
(Mesher2D.getX(encodedMeshedData) << 16) |
(Mesher2D.getZ(encodedMeshedData) << 11);
}
}

View File

@@ -1,12 +1,9 @@
package me.cortex.voxy.client.core.rendering.building;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.longs.Long2ObjectFunction;
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import me.cortex.voxy.client.core.model.IdNotYetComputedException;
import me.cortex.voxy.client.core.model.ModelBakerySubsystem;
import me.cortex.voxy.common.Logger;
import me.cortex.voxy.common.util.Pair;
import me.cortex.voxy.common.world.WorldEngine;
import me.cortex.voxy.common.world.WorldSection;
@@ -14,15 +11,12 @@ import me.cortex.voxy.common.world.other.Mapper;
import me.cortex.voxy.common.thread.ServiceSlice;
import me.cortex.voxy.common.thread.ServiceThreadPool;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.StampedLock;
import java.util.function.BooleanSupplier;
import java.util.function.Consumer;
import java.util.function.Supplier;
//TODO: Add a render cache
@@ -81,7 +75,7 @@ public class RenderGenerationService {
this.threads = serviceThreadPool.createService("Section mesh generation service", 100, ()->{
//Thread local instance of the factory
var factory = new RenderDataFactory45(this.world, this.modelBakery.factory, this.emitMeshlets);
var factory = new RenderDataFactory(this.world, this.modelBakery.factory, this.emitMeshlets);
IntOpenHashSet seenMissed = new IntOpenHashSet(128);
return new Pair<>(() -> {
this.processJob(factory, seenMissed);
@@ -130,7 +124,7 @@ public class RenderGenerationService {
}
//TODO: add a generated render data cache
private void processJob(RenderDataFactory45 factory, IntOpenHashSet seenMissedIds) {
private void processJob(RenderDataFactory factory, IntOpenHashSet seenMissedIds) {
BuildTask task = this.taskQueue.poll();
this.taskQueueCount.decrementAndGet();