// Number of blocks occlusion culled
u32 blocks_occlusion_culled = 0;
+ std::set<v3s16> shortlist;
+ MeshGrid mesh_grid = m_client->getMeshGrid();
+
for (auto §or_it : m_sectors) {
MapSector *sector = sector_it.second;
if (!sector)
Loop through blocks in sector
*/
for (MapBlock *block : sectorblocks) {
- if (!block->mesh) {
- // Ignore if mesh doesn't exist
+ if (mesh_grid.cell_size == 1 && !block->mesh) {
+ // fast out in the case of no mesh chunking
continue;
}
if (projection.getDistanceFrom(block_pos) > radius)
continue;
+ if (mesh_grid.cell_size > 1) {
+ // Block meshes are stored in the corner block of a chunk
+ // (where all coordinate are divisible by the chunk size)
+ // Add them to the de-dup set.
+ shortlist.emplace(mesh_grid.getMeshPos(block->getPos()));
+ }
+ if (!block->mesh) {
+ // Ignore if mesh doesn't exist
+ continue;
+ }
+
blocks_in_range_with_mesh++;
// This block is in range. Reset usage timer.
}
}
}
+ for (auto pos : shortlist) {
+ MapBlock * block = getBlockNoCreateNoEx(pos);
+ if (block && block->mesh && m_drawlist_shadow.emplace(pos, block).second) {
+ block->refGrab();
+ }
+ }
g_profiler->avg("SHADOW MapBlock meshes in range [#]", blocks_in_range_with_mesh);
g_profiler->avg("SHADOW MapBlocks occlusion culled [#]", blocks_occlusion_culled);