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 09c6b95e..9bada669 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 @@ -37,24 +37,6 @@ public class ModelBakerySubsystem { } public void tick() { - //There should be a method to access the frame time IIRC, if the user framecap is unlimited lock it to like 60 fps for computation - int BUDGET = 16;//TODO: make this computed based on the remaining free time in a frame (and like div by 2 to reduce overhead) (with a min of 1) - - for (int i = 0; i < BUDGET && !this.blockIdQueue.isEmpty(); i++) { - int blockId = -1; - synchronized (this.blockIdQueue) { - if (!this.blockIdQueue.isEmpty()) { - blockId = this.blockIdQueue.removeFirstInt(); - VarHandle.fullFence();//Ensure memory coherancy - } else { - break; - } - } - if (blockId != -1) { - this.factory.addEntry(blockId); - } - } - //Upload all biomes while (!this.biomeQueue.isEmpty()) { var biome = this.biomeQueue.poll(); @@ -62,6 +44,28 @@ public class ModelBakerySubsystem { this.factory.addBiome(biome.id, biomeReg.get(Identifier.of(biome.biome))); } + + //There should be a method to access the frame time IIRC, if the user framecap is unlimited lock it to like 60 fps for computation + int BUDGET = 10;//TODO: make this computed based on the remaining free time in a frame (and like div by 2 to reduce overhead) (with a min of 1) + if (!this.blockIdQueue.isEmpty()) { + int[] est = new int[Math.min(this.blockIdQueue.size(), BUDGET)]; + int i = 0; + synchronized (this.blockIdQueue) { + for (;i < est.length && !this.blockIdQueue.isEmpty(); i++) { + int blockId = this.blockIdQueue.removeFirstInt(); + if (blockId == -1) { + i--; + continue; + } + est[i] = blockId; + } + } + + for (int j = 0; j < i; j++) { + this.factory.addEntry(est[j]); + } + } + //Submit is effectively free if nothing is submitted this.textureDownStream.submit(); diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory45.java b/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory45.java index 927f1bf4..2ce51be2 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory45.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory45.java @@ -363,7 +363,7 @@ public class RenderDataFactory45 { { int idx = index + (pidx*32); - int shift = skipAmount * 32; + int shift = skipAmount * 32 * 2; //Flip data with respect to facing direction int iA = idx * 2 + (facingForward == 1 ? 0 : shift);