Do light/cave testing before face-culling to improve performance

This commit is contained in:
Lukas Rieger (Blue) 2024-02-08 15:26:45 +01:00
parent 81e8da3b70
commit 73a77e5e0e
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2

View File

@ -45,10 +45,10 @@
import de.bluecolored.bluemap.core.util.math.MatrixM4f;
import de.bluecolored.bluemap.core.util.math.VectorM2f;
import de.bluecolored.bluemap.core.util.math.VectorM3f;
import de.bluecolored.bluemap.core.world.block.BlockNeighborhood;
import de.bluecolored.bluemap.core.world.BlockProperties;
import de.bluecolored.bluemap.core.world.block.ExtendedBlock;
import de.bluecolored.bluemap.core.world.LightData;
import de.bluecolored.bluemap.core.world.block.BlockNeighborhood;
import de.bluecolored.bluemap.core.world.block.ExtendedBlock;
/**
* This model builder creates a BlockStateModel using the information from parsed resource-pack json files.
@ -179,14 +179,6 @@ private void createElementFace(Element element, Direction faceDir, VectorM3f c0,
Vector3i faceDirVector = faceDir.toVector();
// face culling
if (face.getCullface() != null) {
ExtendedBlock<?> b = getRotationRelativeBlock(face.getCullface());
BlockProperties p = b.getProperties();
if (p.isCulling()) return;
if (p.getCullingIdentical() && b.getBlockState().equals(block.getBlockState())) return;
}
// light calculation
ExtendedBlock<?> facedBlockNeighbor = getRotationRelativeBlock(faceDir);
LightData blockLightData = block.getLightData();
@ -201,6 +193,14 @@ private void createElementFace(Element element, Direction faceDir, VectorM3f c0,
(renderSettings.isCaveDetectionUsesBlockLight() ? Math.max(blockLight, sunLight) : sunLight) == 0
) return;
// face culling
if (face.getCullface() != null) {
ExtendedBlock<?> b = getRotationRelativeBlock(face.getCullface());
BlockProperties p = b.getProperties();
if (p.isCulling()) return;
if (p.getCullingIdentical() && b.getBlockState().equals(block.getBlockState())) return;
}
// initialize the faces
blockModel.initialize();
blockModel.add(2);