From 8d4d823537517a4bc476a3d9f4f9bf409a576704 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Mon, 27 Oct 2025 10:15:48 +1000 Subject: [PATCH] async model processing --- .../core/model/ModelBakerySubsystem.java | 33 +++++++++++++++---- .../voxy/client/core/model/ModelFactory.java | 4 ++- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/main/java/me/cortex/voxy/client/core/model/ModelBakerySubsystem.java b/src/main/java/me/cortex/voxy/client/core/model/ModelBakerySubsystem.java index b1cc5b1a..c30fb455 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/ModelBakerySubsystem.java +++ b/src/main/java/me/cortex/voxy/client/core/model/ModelBakerySubsystem.java @@ -28,15 +28,30 @@ public class ModelBakerySubsystem { private final AtomicInteger blockIdCount = new AtomicInteger(); private final ConcurrentLinkedDeque blockIdQueue = new ConcurrentLinkedDeque<>();//TODO: replace with custom DS + private final Thread processingThread; + private volatile boolean isRunning = true; public ModelBakerySubsystem(Mapper mapper) { this.mapper = mapper; this.factory = new ModelFactory(mapper, this.storage); + this.processingThread = new Thread(()->{ + while (this.isRunning) { + this.factory.processAllThings(); + try { + Thread.sleep(50); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + }, "Model factory processor"); + this.processingThread.start(); } public void tick(long totalBudget) { - if (this.blockIdCount.get() != 0) { - //Always do 1 iteration minimum - Integer i = this.blockIdQueue.poll(); + long start = System.nanoTime(); + this.factory.tickAndProcessUploads(); + //Always do 1 iteration minimum + Integer i = this.blockIdQueue.poll(); + if (i != null) { int j = 0; if (i != null) { int fbBinding = glGetInteger(GL_FRAMEBUFFER_BINDING); @@ -44,7 +59,7 @@ public class ModelBakerySubsystem { do { this.factory.addEntry(i); j++; - if (24