Fixes for tasks never finishing
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user