Fix critical issue with meshing
This commit is contained in:
@@ -332,7 +332,7 @@ public class RenderDataFactory45 {
|
||||
if (Mapper.getBlockId(neighborId) != 0) {//Not air
|
||||
long meta = this.modelMan.getModelMetadataFromClientId(this.modelMan.getModelId(Mapper.getBlockId(neighborId)));
|
||||
if (ModelQueries.isFullyOpaque(meta)) {//Dont mesh this face
|
||||
this.blockMesher.putNext(0);
|
||||
this.blockMesher.skip(1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -535,6 +535,10 @@ public class RenderDataFactory45 {
|
||||
}
|
||||
}
|
||||
|
||||
for (var mesher : this.xAxisMeshers) {
|
||||
mesher.finish();
|
||||
}
|
||||
|
||||
//Generate the side faces, hackily, using 0 and 1 mesher
|
||||
if (true) {
|
||||
var ma = this.xAxisMeshers[0];
|
||||
@@ -543,6 +547,7 @@ public class RenderDataFactory45 {
|
||||
mb.finish();
|
||||
ma.doAuxiliaryFaceOffset = false;
|
||||
mb.doAuxiliaryFaceOffset = false;
|
||||
|
||||
for (int y = 0; y < 32; y++) {
|
||||
int skipA = 0;
|
||||
int skipB = 0;
|
||||
@@ -584,15 +589,12 @@ public class RenderDataFactory45 {
|
||||
ma.skip(skipA);
|
||||
mb.skip(skipB);
|
||||
}
|
||||
|
||||
ma.finish();
|
||||
mb.finish();
|
||||
ma.doAuxiliaryFaceOffset = true;
|
||||
mb.doAuxiliaryFaceOffset = true;
|
||||
}
|
||||
|
||||
for (var mesher : this.xAxisMeshers) {
|
||||
mesher.finish();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -607,11 +609,26 @@ public class RenderDataFactory45 {
|
||||
|
||||
//section is already acquired and gets released by the parent
|
||||
public BuiltSection generateMesh(WorldSection section) {
|
||||
//TODO: FIXME: because of the exceptions that are thrown when aquiring modelId
|
||||
// this can result in the state of all block meshes and well _everything_ from being incorrect
|
||||
//THE EXCEPTION THAT THIS THROWS CAUSES MAJOR ISSUES
|
||||
|
||||
//Copy section data to end of array so that can mutate array while reading safely
|
||||
section.copyDataTo(this.sectionData, 32*32*32);
|
||||
|
||||
//We must reset _everything_ that could have changed as we dont exactly know the state due to how the model id exception
|
||||
// throwing system works
|
||||
this.quadCount = 0;
|
||||
|
||||
{//Reset all the block meshes
|
||||
this.blockMesher.reset();
|
||||
this.blockMesher.doAuxiliaryFaceOffset = true;
|
||||
for (var mesher : this.xAxisMeshers) {
|
||||
mesher.reset();
|
||||
mesher.doAuxiliaryFaceOffset = true;
|
||||
}
|
||||
}
|
||||
|
||||
this.minX = Integer.MAX_VALUE;
|
||||
this.minY = Integer.MAX_VALUE;
|
||||
this.minZ = Integer.MAX_VALUE;
|
||||
|
||||
@@ -100,15 +100,18 @@ public abstract class ScanMesher2D {
|
||||
if (count == 0) return;
|
||||
//TODO: replace with much better method, TODO: check this is right!!
|
||||
this.putNext(0);
|
||||
if (1<count) {
|
||||
this.emitRanged(((1 << (count - 1)) - 1) << (this.currentIndex & 31));
|
||||
this.currentIndex += count - 1;
|
||||
}
|
||||
/*
|
||||
for (int i = 0; i < count; i++) {
|
||||
this.putNext(0);
|
||||
}*/
|
||||
}
|
||||
|
||||
public final void resetScanlineRowIndex() {
|
||||
public final void reset() {
|
||||
this.rowBitset = 0;
|
||||
this.currentSum = 0;
|
||||
this.currentData = 0;
|
||||
this.currentIndex = 0;
|
||||
@@ -132,12 +135,13 @@ public abstract class ScanMesher2D {
|
||||
for (int i = 0; i < 32; i++) {
|
||||
this.putNext(0);
|
||||
}*/
|
||||
|
||||
//TODO: check this is correct
|
||||
if (this.currentIndex != 0) {
|
||||
this.skip(32 - (this.currentIndex & 31));
|
||||
this.emitRanged(-1);
|
||||
}
|
||||
|
||||
this.resetScanlineRowIndex();
|
||||
this.reset();
|
||||
}
|
||||
|
||||
protected abstract void emitQuad(int x, int z, int length, int width, long data);
|
||||
|
||||
Reference in New Issue
Block a user