1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-06 17:41:04 +00:00

Add depth sorting for node faces (#11696)

Use BSP tree to order transparent triangles
https://en.wikipedia.org/wiki/Binary_space_partitioning
This commit is contained in:
x2048 2022-04-02 10:42:27 +02:00 committed by GitHub
parent 26c046a563
commit b0b9732359
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 628 additions and 92 deletions

View file

@ -260,6 +260,18 @@ struct TileLayer
&& (material_flags & MATERIAL_FLAG_TILEABLE_VERTICAL);
}
bool isTransparent() const
{
switch (material_type) {
case TILE_MATERIAL_BASIC:
case TILE_MATERIAL_ALPHA:
case TILE_MATERIAL_LIQUID_TRANSPARENT:
case TILE_MATERIAL_WAVING_LIQUID_TRANSPARENT:
return true;
}
return false;
}
// Ordered for size, please do not reorder
video::ITexture *texture = nullptr;
@ -308,7 +320,8 @@ struct TileSpec
for (int layer = 0; layer < MAX_TILE_LAYERS; layer++) {
if (layers[layer] != other.layers[layer])
return false;
if (!layers[layer].isTileable())
// Only non-transparent tiles can be merged into fast faces
if (layers[layer].isTransparent() || !layers[layer].isTileable())
return false;
}
return rotation == 0