From f536b0cd74cf2aa0065e7b99a7b29f3d9a640098 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Wed, 7 Aug 2024 23:10:42 +1000 Subject: [PATCH] cache --- .../cortex/voxy/common/world/service/VoxelIngestService.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/cortex/voxy/common/world/service/VoxelIngestService.java b/src/main/java/me/cortex/voxy/common/world/service/VoxelIngestService.java index 8375ef8d..70514bfb 100644 --- a/src/main/java/me/cortex/voxy/common/world/service/VoxelIngestService.java +++ b/src/main/java/me/cortex/voxy/common/world/service/VoxelIngestService.java @@ -20,6 +20,7 @@ import java.util.concurrent.ConcurrentLinkedDeque; import java.util.concurrent.Semaphore; public class VoxelIngestService { + private static final ThreadLocal SECTION_CACHE = ThreadLocal.withInitial(VoxelizedSection::createEmpty); private final ServiceSlice threads; private final ConcurrentLinkedDeque ingestQueue = new ConcurrentLinkedDeque<>(); private final ConcurrentHashMap> captureLightMap = new ConcurrentHashMap<>(1000,0.75f, 7); @@ -41,7 +42,7 @@ public class VoxelIngestService { this.world.insertUpdate(VoxelizedSection.createEmpty().setPosition(chunk.getPos().x, i, chunk.getPos().z)); } else { VoxelizedSection csec = WorldConversionFactory.convert( - VoxelizedSection.createEmpty().setPosition(chunk.getPos().x, i, chunk.getPos().z), + SECTION_CACHE.get().setPosition(chunk.getPos().x, i, chunk.getPos().z), this.world.getMapper(), section.getBlockStateContainer(), section.getBiomeContainer(), @@ -49,7 +50,7 @@ public class VoxelIngestService { if (lighting == null || ((lighting.first() != null && lighting.first().isUninitialized())&&(lighting.second()!=null&&lighting.second().isUninitialized()))) { return (byte) 0x0f; } else { - //Lighting is a piece of shit cause its done per face + //Lighting is hell int block = lighting.first()!=null?Math.min(15,lighting.first().get(x, y, z)):0; int sky = lighting.second()!=null?Math.min(15,lighting.second().get(x, y, z)):0; if (block