mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2025-01-25 09:41:21 +01:00
Swap chunk-scan direction for future stuff :)
This commit is contained in:
parent
c9a8c83d6e
commit
2899646adc
@ -78,7 +78,7 @@ public void render(World world, Vector3i modelMin, Vector3i modelMax, TileModel
|
||||
minY = Math.max(min.getY(), chunk.getMinY(x, z));
|
||||
maxY = Math.min(max.getY(), chunk.getMaxY(x, z));
|
||||
|
||||
for (y = minY; y <= maxY; y++) {
|
||||
for (y = maxY; y >= minY; y--) {
|
||||
block.set(x, y, z);
|
||||
if (!block.isInsideRenderBounds()) continue;
|
||||
|
||||
@ -87,17 +87,7 @@ public void render(World world, Vector3i modelMin, Vector3i modelMax, TileModel
|
||||
modelFactory.render(block, blockModel, blockColor);
|
||||
|
||||
//update topBlockLight
|
||||
if (
|
||||
y >= renderSettings.getRemoveCavesBelowY() ||
|
||||
(renderSettings.isCaveDetectionUsesBlockLight() ? block.getBlockLightLevel() : block.getSunLightLevel()) > 0
|
||||
) {
|
||||
if (blockColor.a > 0) {
|
||||
topBlockLight = Math.floor(topBlockLight * (1 - blockColor.a));
|
||||
}
|
||||
topBlockLight = Math.max(topBlockLight, block.getBlockLightLevel());
|
||||
} else {
|
||||
topBlockLight = 0;
|
||||
}
|
||||
topBlockLight = Math.max(topBlockLight, block.getBlockLightLevel() * (1 - columnColor.a));
|
||||
|
||||
// skip empty blocks
|
||||
if (blockModel.getSize() <= 0) continue;
|
||||
@ -107,9 +97,11 @@ public void render(World world, Vector3i modelMin, Vector3i modelMax, TileModel
|
||||
|
||||
//update color and height (only if not 100% translucent)
|
||||
if (blockColor.a > 0) {
|
||||
maxHeight = y;
|
||||
columnColor.overlay(blockColor.premultiplied());
|
||||
if (maxHeight < y) maxHeight = y;
|
||||
columnColor.underlay(blockColor.premultiplied());
|
||||
}
|
||||
|
||||
//if (blockColor.a > 0.999 && block.getProperties().isCulling()) break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,17 @@ private void createElementFace(Element element, Direction faceDir, VectorM3f c0,
|
||||
(renderSettings.isCaveDetectionUsesBlockLight() ? Math.max(blockLight, sunLight) : sunLight) == 0
|
||||
) return;
|
||||
|
||||
// calculate faceRotationVector
|
||||
faceRotationVector.set(
|
||||
faceDirVector.getX(),
|
||||
faceDirVector.getY(),
|
||||
faceDirVector.getZ()
|
||||
);
|
||||
faceRotationVector.rotateAndScale(element.getRotation().getMatrix());
|
||||
makeRotationRelative(faceRotationVector);
|
||||
|
||||
// face culling
|
||||
//if (faceRotationVector.y < 0.01) return;
|
||||
if (face.getCullface() != null) {
|
||||
ExtendedBlock<?> b = getRotationRelativeBlock(face.getCullface());
|
||||
BlockProperties p = b.getProperties();
|
||||
@ -315,14 +325,6 @@ private void createElementFace(Element element, Direction faceDir, VectorM3f c0,
|
||||
tileModel.setAOs(face2, ao0, ao2, ao3);
|
||||
|
||||
//if is top face set model-color
|
||||
faceRotationVector.set(
|
||||
faceDirVector.getX(),
|
||||
faceDirVector.getY(),
|
||||
faceDirVector.getZ()
|
||||
);
|
||||
faceRotationVector.rotateAndScale(element.getRotation().getMatrix());
|
||||
makeRotationRelative(faceRotationVector);
|
||||
|
||||
float a = faceRotationVector.y;
|
||||
if (a > 0.01 && texturePath != null) {
|
||||
Texture texture = texturePath.getResource(resourcePack::getTexture);
|
||||
|
@ -125,6 +125,20 @@ public Color overlay(Color color) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Color underlay(Color color) {
|
||||
if (color.a < 1f && !color.premultiplied) throw new IllegalArgumentException("Can only underlay premultiplied colors with alpha!");
|
||||
|
||||
premultiplied();
|
||||
|
||||
float p = 1 - a;
|
||||
this.a = p * color.a + this.a;
|
||||
this.r = p * color.r + this.r;
|
||||
this.g = p * color.g + this.g;
|
||||
this.b = p * color.b + this.b;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Color flatten() {
|
||||
if (this.a == 1f) return this;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user