Merged zy into single method

This commit is contained in:
mcrcortex
2024-12-05 10:19:43 +10:00
parent 622c40f188
commit 70a1fe36c7

View File

@@ -142,13 +142,19 @@ public class RenderDataFactory4 {
} }
} }
private void generateYFaces() {
this.blockMesher.axis = 0;// Y axis
for (int y = 0; y < 31; y++) { private void generateYZFaces() {
this.blockMesher.auxiliaryPosition = y; for (int axis = 0; axis < 2; axis++) {
for (int z = 0; z < 32; z++) {//TODO: need to do the faces that border sections this.blockMesher.axis = axis;
int current = this.opaqueMasks[(y+0)*32+z]; for (int layer = 0; layer < 31; layer++) {
int next = this.opaqueMasks[(y+1)*32+z]; this.blockMesher.auxiliaryPosition = layer;
for (int other = 0; other < 32; other++) {//TODO: need to do the faces that border sections
int pidx = axis==0 ?(layer*32+other):(other*32+layer);
int skipAmount = axis==0?32:1;
int current = this.opaqueMasks[pidx];
int next = this.opaqueMasks[pidx + skipAmount];
int msk = current ^ next; int msk = current ^ next;
if (msk == 0) { if (msk == 0) {
@@ -157,30 +163,30 @@ public class RenderDataFactory4 {
} }
//TODO: For boarder sections, should NOT EMIT neighbors faces //TODO: For boarder sections, should NOT EMIT neighbors faces
int faceForwardMsk = msk&current; int faceForwardMsk = msk & current;
int cIdx = -1; int cIdx = -1;
while (msk!=0) { while (msk != 0) {
int index = Integer.numberOfTrailingZeros(msk);//Is also the x-axis index int index = Integer.numberOfTrailingZeros(msk);//Is also the x-axis index
int delta = index - cIdx - 1; cIdx = index; //index--; int delta = index - cIdx - 1;
cIdx = index; //index--;
if (delta != 0) this.blockMesher.skip(delta); if (delta != 0) this.blockMesher.skip(delta);
msk &= ~Integer.lowestOneBit(msk); msk &= ~Integer.lowestOneBit(msk);
int facingForward = ((faceForwardMsk>>index)&1); int facingForward = ((faceForwardMsk >> index) & 1);
{ {
int idx = index + (z * 32) + (y * 32 * 32); int idx = index + (pidx*32);
//TODO: swap this out for something not getting the next entry //TODO: swap this out for something not getting the next entry
long A = this.sectionData[idx * 2]; long A = this.sectionData[idx * 2];
long B = this.sectionData[(idx + 32*32) * 2]; long B = this.sectionData[(idx + skipAmount * 32) * 2];
//Flip data with respect to facing direction //Flip data with respect to facing direction
long selfModel = facingForward==1?A:B; long selfModel = facingForward == 1 ? A : B;
long nextModel = facingForward==1?B:A; long nextModel = facingForward == 1 ? B : A;
//Example thing thats just wrong but as example //Example thing thats just wrong but as example
this.blockMesher.putNext((long) facingForward | ((selfModel&0xFFFF)<<26) | (0xFFL<<55)); this.blockMesher.putNext((long) facingForward | ((selfModel & 0xFFFF) << 26) | (0xFFL << 55));
} }
} }
this.blockMesher.endRow(); this.blockMesher.endRow();
@@ -188,53 +194,6 @@ public class RenderDataFactory4 {
this.blockMesher.finish(); this.blockMesher.finish();
} }
} }
private void generateZFaces() {
this.blockMesher.axis = 1;// Z axis
for (int z = 0; z < 31; z++) {
this.blockMesher.auxiliaryPosition = z;
for (int y = 0; y < 32; y++) {//TODO: need to do the faces that border sections
int current = this.opaqueMasks[y*32+z];
int next = this.opaqueMasks[y*32+z+1];
int msk = current ^ next;
if (msk == 0) {
this.blockMesher.skip(32);
continue;
}
//TODO: For boarder sections, should NOT EMIT neighbors faces
int faceForwardMsk = msk&current;
int cIdx = -1;
while (msk!=0) {
int index = Integer.numberOfTrailingZeros(msk);//Is also the x-axis index
int delta = index - cIdx - 1; cIdx = index; //index--;
if (delta != 0) this.blockMesher.skip(delta);
msk &= ~Integer.lowestOneBit(msk);
int facingForward = ((faceForwardMsk>>index)&1);
{
int idx = index + (z * 32) + (y * 32 * 32);
//TODO: swap this out for something not getting the next entry
long A = this.sectionData[idx * 2];
long B = this.sectionData[(idx + 32) * 2];
//Flip data with respect to facing direction
long selfModel = facingForward==1?A:B;
long nextModel = facingForward==1?B:A;
//Example thing thats just wrong but as example
this.blockMesher.putNext((long) facingForward | ((selfModel&0xFFFF)<<26) | (0xFFL<<55));
}
}
this.blockMesher.endRow();
}
this.blockMesher.finish();
}
} }
@@ -369,10 +328,6 @@ public class RenderDataFactory4 {
} }
} }
public static void main(String[] args) {
System.out.println(1L<<(-555));
}
/* /*
private static long createQuad() { private static long createQuad() {
((long)clientModelId) | (((long) Mapper.getLightId(ModelQueries.faceUsesSelfLighting(metadata, face)?self:facingState))<<16) | ((((long) Mapper.getBiomeId(self))<<24) * (ModelQueries.isBiomeColoured(metadata)?1:0)) | otherFlags ((long)clientModelId) | (((long) Mapper.getLightId(ModelQueries.faceUsesSelfLighting(metadata, face)?self:facingState))<<16) | ((((long) Mapper.getBiomeId(self))<<24) * (ModelQueries.isBiomeColoured(metadata)?1:0)) | otherFlags
@@ -411,9 +366,7 @@ public class RenderDataFactory4 {
//Prepare everything //Prepare everything
this.prepareSectionData(); this.prepareSectionData();
this.generateYFaces(); this.generateYZFaces();
this.generateZFaces();
this.generateXFaces(); this.generateXFaces();