This commit is contained in:
mcrcortex
2025-03-28 09:49:12 +10:00
parent e812b13ef7
commit 8b3f8812de
5 changed files with 71 additions and 55 deletions

View File

@@ -52,7 +52,7 @@ public class RenderService<T extends AbstractSectionRenderer<J, ?>, J extends Vi
//Max sections: ~500k
//Max geometry: 1 gb
this.sectionRenderer = (T) createSectionRenderer(this.modelService.getStore(),1<<20, (1L<<32)-1024);
this.sectionRenderer = (T) createSectionRenderer(this.modelService.getStore(),1<<20, (1L<<31)-1024);
Logger.info("Using renderer: " + this.sectionRenderer.getClass().getSimpleName());
//Do something incredibly hacky, we dont need to keep the reference to this around, so just connect and discard

View File

@@ -277,7 +277,8 @@ public class RenderDataFactory45 {
private void generateYZOpaqueInnerGeometry(int axis) {
for (int layer = 0; layer < 31; layer++) {
this.blockMesher.auxiliaryPosition = layer;
for (int other = 0; other < 32; other++) {//TODO: need to do the faces that border sections
int cSkip = 0;
for (int other = 0; other < 32; other++) {
int pidx = axis==0 ?(layer*32+other):(other*32+layer);
int skipAmount = axis==0?32:1;
@@ -286,10 +287,13 @@ public class RenderDataFactory45 {
int msk = current ^ next;
if (msk == 0) {
this.blockMesher.skip(32);
cSkip += 32;
continue;
}
this.blockMesher.skip(cSkip);
cSkip = 0;
//TODO: For boarder sections, should NOT EMIT neighbors faces
int faceForwardMsk = msk & current;
int cIdx = -1;
@@ -321,6 +325,7 @@ public class RenderDataFactory45 {
);
}
}
this.blockMesher.endRow();
}
this.blockMesher.finish();
@@ -333,14 +338,18 @@ public class RenderDataFactory45 {
for (int side = 0; side < 2; side++) {//-, +
int layer = side == 0 ? 0 : 31;
this.blockMesher.auxiliaryPosition = layer;
int cSkips = 0;
for (int other = 0; other < 32; other++) {
int pidx = axis == 0 ? (layer * 32 + other) : (other * 32 + layer);
int msk = this.opaqueMasks[pidx];
if (msk == 0) {
this.blockMesher.skip(32);
cSkips += 32;
continue;
}
this.blockMesher.skip(cSkips);
cSkips = 0;
int cIdx = -1;
while (msk != 0) {
int index = Integer.numberOfTrailingZeros(msk);//Is also the x-axis index
@@ -384,6 +393,54 @@ public class RenderDataFactory45 {
this.blockMesher.doAuxiliaryFaceOffset = true;
}
private void generateYZNonOpaqueInnerGeometry(int axis) {
//Note: think is ok to just reuse.. blockMesher
this.blockMesher.axis = axis;
for (int layer = 0; layer < 32; layer++) {
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 msk = this.nonOpaqueMasks[pidx];
if (msk == 0) {
this.blockMesher.skip(32);
continue;
}
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 idx = index + (pidx * 32);
//TODO: swap this out for something not getting the next entry
long A = this.sectionData[idx * 2];
long B = this.sectionData[idx * 2+1];
if (ModelQueries.isTranslucent(B)) {
this.blockMesher.putNext(0);
continue;
}
//Example thing thats just wrong but as example
this.blockMesher.putNext((long) (false ? 0L : 1L) |
((A & 0xFFFFL) << 26) |
(((0xFFL) & 0xFF) << 55) |
((A&(0x1FFL<<24))<<(46-24))
);
}
}
this.blockMesher.endRow();
}
this.blockMesher.finish();
}
}
private void generateYZFaces() {
for (int axis = 0; axis < 2; axis++) {//Y then Z
this.blockMesher.axis = axis;
@@ -391,54 +448,7 @@ public class RenderDataFactory45 {
this.generateYZOpaqueInnerGeometry(axis);
this.generateYZOpaqueOuterGeometry(axis);
if (false) {//Non fully opaque geometry
//Note: think is ok to just reuse.. blockMesher
this.blockMesher.axis = axis;
for (int layer = 0; layer < 32; layer++) {
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 msk = this.nonOpaqueMasks[pidx];
if (msk == 0) {
this.blockMesher.skip(32);
continue;
}
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 idx = index + (pidx * 32);
//TODO: swap this out for something not getting the next entry
long A = this.sectionData[idx * 2];
long B = this.sectionData[idx * 2+1];
if (ModelQueries.isFluid(B)) {
this.blockMesher.putNext(0);
continue;
}
//Example thing thats just wrong but as example
this.blockMesher.putNext((long) (false ? 0L : 1L) |
((A & 0xFFFFL) << 26) |
(((0xFFL) & 0xFF) << 55) |
((A&(0x1FFL<<24))<<(46-24))
);
}
}
this.blockMesher.endRow();
}
this.blockMesher.finish();
}
}
//this.generateYZNonOpaqueInnerGeometry(axis);
}
}

View File

@@ -101,7 +101,7 @@ public abstract class ScanMesher2D {
//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.emitRanged(((1 << (Math.min(count, 32) - 1)) - 1) << (this.currentIndex & 31));
this.currentIndex += count - 1;
}
/*

View File

@@ -28,7 +28,13 @@ public class Logger {
String error = (INSERT_CLASS?("["+stackEntry.getClassName()+"]: "):"") + Stream.of(args).map(Logger::objToString).collect(Collectors.joining(" "));
LOGGER.error(error, throwable);
if (VoxyCommon.IS_IN_MINECRAFT && !VoxyCommon.IS_DEDICATED_SERVER) {
MinecraftClient.getInstance().executeSync(()->{var player = MinecraftClient.getInstance().player; if (player != null) player.sendMessage(Text.literal(error), true);});
var instance = MinecraftClient.getInstance();
if (instance != null) {
instance.executeSync(() -> {
var player = MinecraftClient.getInstance().player;
if (player != null) player.sendMessage(Text.literal(error), true);
});
}
}
}

View File

@@ -30,7 +30,7 @@ public class VoxyCommon implements ModInitializer {
}
//This is hardcoded like this because people do not understand what they are doing
private static final boolean GlobalVerificationDisableOverride = true;//System.getProperty("voxy.verificationDisableOverride", "false").equals("true");
private static final boolean GlobalVerificationDisableOverride = false;//System.getProperty("voxy.verificationDisableOverride", "false").equals("true");
public static boolean isVerificationFlagOn(String name) {
return (!GlobalVerificationDisableOverride) && System.getProperty("voxy."+name, "true").equals("true");
}