mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Reduce server CPU consumed by occlusion culling. (#13260)
Cache blocks already occluded at a specific distance. The RemoteClient typically visits the same distance multiple time - especially at larger distances, so this saves significant CPU from recalculating the occlusion state of blocks.
This commit is contained in:
parent
9ef3c8ce38
commit
1f0d042377
2 changed files with 23 additions and 4 deletions
|
@ -328,8 +328,15 @@ void RemoteClient::GetNextBlocks (
|
|||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
Check occlusion cache first.
|
||||
*/
|
||||
if (m_blocks_occ.find(p) != m_blocks_occ.end())
|
||||
continue;
|
||||
|
||||
if (m_occ_cull && !block_not_found &&
|
||||
env->getMap().isBlockOccluded(block, cam_pos_nodes)) {
|
||||
m_blocks_occ.insert(p);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -395,8 +402,11 @@ queue_full_break:
|
|||
}
|
||||
}
|
||||
|
||||
if (new_nearest_unsent_d != -1)
|
||||
if (new_nearest_unsent_d != -1 && m_nearest_unsent_d != new_nearest_unsent_d) {
|
||||
m_nearest_unsent_d = new_nearest_unsent_d;
|
||||
// if the distance has changed, clear the occlusion cache
|
||||
m_blocks_occ.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void RemoteClient::GotBlock(v3s16 p)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue