1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Occlusion culling algorithm based on recursive descend (#13104)

Co-authored-by: DS <vorunbekannt75@web.de>
This commit is contained in:
x2048 2023-01-06 22:31:06 +01:00 committed by GitHub
parent 059f62d7d6
commit 2715cc8bf6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 493 additions and 58 deletions

View file

@ -1582,3 +1582,31 @@ video::SColor encode_light(u16 light, u8 emissive_light)
float b = (day + night) / 2;
return video::SColor(r, b, b, b);
}
u8 get_solid_sides(MeshMakeData *data)
{
v3s16 blockpos_nodes = data->m_blockpos * MAP_BLOCKSIZE;
const NodeDefManager *ndef = data->m_client->ndef();
u8 result = 0x3F; // all sides solid;
for (s16 i = 0; i < MAP_BLOCKSIZE && result != 0; i++)
for (s16 j = 0; j < MAP_BLOCKSIZE && result != 0; j++) {
v3s16 positions[6] = {
v3s16(0, i, j),
v3s16(MAP_BLOCKSIZE - 1, i, j),
v3s16(i, 0, j),
v3s16(i, MAP_BLOCKSIZE - 1, j),
v3s16(i, j, 0),
v3s16(i, j, MAP_BLOCKSIZE - 1)
};
for (u8 k = 0; k < 6; k++) {
const MapNode &top = data->m_vmanip.getNodeRefUnsafe(blockpos_nodes + positions[k]);
if (ndef->get(top).solidness != 2)
result &= ~(1 << k);
}
}
return result;
}