From 9b08c6e5ff5db4fa6881521fc4408e6b7b3b6f49 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Thu, 1 Aug 2024 15:51:20 +1000 Subject: [PATCH] Fixes for tasks never finishing --- .../client/core/model/IdNotYetComputedException.java | 2 ++ .../core/rendering/building/RenderDataFactory.java | 9 ++++----- .../core/rendering/building/RenderGenerationService.java | 9 +++++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/cortex/voxy/client/core/model/IdNotYetComputedException.java b/src/main/java/me/cortex/voxy/client/core/model/IdNotYetComputedException.java index 2a87971f..e21d86e0 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/IdNotYetComputedException.java +++ b/src/main/java/me/cortex/voxy/client/core/model/IdNotYetComputedException.java @@ -1,7 +1,9 @@ package me.cortex.voxy.client.core.model; public class IdNotYetComputedException extends RuntimeException { + public final int id; public IdNotYetComputedException(int id) { super("Id not yet computed: " + id); + this.id = id; } } diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory.java b/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory.java index 3cf223a6..f77f3f71 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory.java @@ -470,7 +470,6 @@ public class RenderDataFactory { - //TODO:FIXME SOMEHOW THIS IS CRITICAL!!!!!!!!!!!!!!!!!! // so there is one more issue need to be fixed, if water is layered ontop of eachother, the side faces depend on the water state ontop // this has been hackfixed in the model texture bakery but a proper solution that doesnt explode the sides of the water textures needs to be done @@ -488,13 +487,13 @@ public class RenderDataFactory { //Returns true if a face was placed private boolean putFaceIfCan(Mesher2D mesher, int face, int opposingFace, long self, long metadata, int clientModelId, int selfBlockId, long facingState, long facingMetadata, int a, int b) { - //If face can be occluded and is occluded from the facing block, then dont render the face - if (ModelQueries.faceCanBeOccluded(metadata, face) && ModelQueries.faceOccludes(facingMetadata, opposingFace)) { + if (ModelQueries.cullsSame(metadata) && selfBlockId == Mapper.getBlockId(facingState)) { + //If we are facing a block, and we are both the same state, dont render that face return false; } - if (ModelQueries.cullsSame(metadata) && selfBlockId == Mapper.getBlockId(facingState)) { - //If we are facing a block, and we are both the same state, dont render that face + //If face can be occluded and is occluded from the facing block, then dont render the face + if (ModelQueries.faceCanBeOccluded(metadata, face) && ModelQueries.faceOccludes(facingMetadata, opposingFace)) { return false; } diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderGenerationService.java b/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderGenerationService.java index 2848f249..cf53c624 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderGenerationService.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderGenerationService.java @@ -50,9 +50,10 @@ public class RenderGenerationService { //NOTE: the biomes are always fully populated/kept up to date //Asks the Model system to bake all blocks that currently dont have a model - private void computeAndRequestRequiredModels(WorldSection section) { + private void computeAndRequestRequiredModels(WorldSection section, int extraId) { var raw = section.copyData();//TODO: replace with copyDataTo and use a "thread local"/context array to reduce allocation rates IntOpenHashSet seen = new IntOpenHashSet(128); + seen.add(extraId); for (long state : raw) { int block = Mapper.getBlockId(state); if (!this.modelBakery.factory.hasModelForBlockId(block)) { @@ -85,6 +86,9 @@ public class RenderGenerationService { try { mesh = factory.generateMesh(section); } catch (IdNotYetComputedException e) { + if (!this.modelBakery.factory.hasModelForBlockId(e.id)) { + this.modelBakery.requestBlockBake(e.id); + } if (task.hasDoneModelRequest[0]) { try { Thread.sleep(10); @@ -92,7 +96,8 @@ public class RenderGenerationService { throw new RuntimeException(ex); } } else { - this.computeAndRequestRequiredModels(section); + //The reason for the extra id parameter is that we explicitly add/check against the exception id due to e.g. requesting accross a chunk boarder wont be captured in the request + this.computeAndRequestRequiredModels(section, e.id); } //We need to reinsert the build task into the queue //System.err.println("Render task failed to complete due to un-computed client id");