mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-05 19:31:04 +00:00
Add a bit of debug code around MapBlock refcounting
This commit is contained in:
parent
39417cf7a7
commit
0c12c1f400
6 changed files with 74 additions and 31 deletions
|
@ -202,8 +202,14 @@ void ClientMap::onSettingChanged(std::string_view name, bool all)
|
|||
|
||||
ClientMap::~ClientMap()
|
||||
{
|
||||
verbosestream << FUNCTION_NAME << std::endl;
|
||||
|
||||
g_settings->deregisterAllChangedCallbacks(this);
|
||||
|
||||
// avoid refcount warning from ~Map()
|
||||
clearDrawList();
|
||||
clearDrawListShadow();
|
||||
|
||||
for (auto &it : m_dynamic_buffers)
|
||||
it.second.drop();
|
||||
}
|
||||
|
@ -351,23 +357,29 @@ private:
|
|||
v3s16 volume;
|
||||
};
|
||||
|
||||
void ClientMap::updateDrawList()
|
||||
void ClientMap::clearDrawList()
|
||||
{
|
||||
ScopeProfiler sp(g_profiler, "CM::updateDrawList()", SPT_AVG);
|
||||
|
||||
m_needs_update_drawlist = false;
|
||||
|
||||
for (auto &i : m_drawlist) {
|
||||
MapBlock *block = i.second;
|
||||
block->refDrop();
|
||||
}
|
||||
m_drawlist.clear();
|
||||
|
||||
for (auto &block : m_keeplist) {
|
||||
for (auto &block : m_keeplist)
|
||||
block->refDrop();
|
||||
}
|
||||
m_keeplist.clear();
|
||||
|
||||
m_needs_update_drawlist = true;
|
||||
}
|
||||
|
||||
void ClientMap::updateDrawList()
|
||||
{
|
||||
ScopeProfiler sp(g_profiler, "CM::updateDrawList()", SPT_AVG);
|
||||
|
||||
clearDrawList();
|
||||
|
||||
m_needs_update_drawlist = false;
|
||||
|
||||
const v3s16 cam_pos_nodes = floatToInt(m_camera_position, BS);
|
||||
|
||||
v3s16 p_blocks_min;
|
||||
|
@ -1519,6 +1531,15 @@ void ClientMap::renderMapShadows(video::IVideoDriver *driver,
|
|||
g_profiler->avg(prefix + "material swaps [#]", material_swaps);
|
||||
}
|
||||
|
||||
void ClientMap::clearDrawListShadow()
|
||||
{
|
||||
for (auto &i : m_drawlist_shadow) {
|
||||
MapBlock *block = i.second;
|
||||
block->refDrop();
|
||||
}
|
||||
m_drawlist_shadow.clear();
|
||||
}
|
||||
|
||||
/*
|
||||
Custom update draw list for the pov of shadow light.
|
||||
*/
|
||||
|
@ -1526,11 +1547,7 @@ void ClientMap::updateDrawListShadow(v3f shadow_light_pos, v3f shadow_light_dir,
|
|||
{
|
||||
ScopeProfiler sp(g_profiler, "CM::updateDrawListShadow()", SPT_AVG);
|
||||
|
||||
for (auto &i : m_drawlist_shadow) {
|
||||
MapBlock *block = i.second;
|
||||
block->refDrop();
|
||||
}
|
||||
m_drawlist_shadow.clear();
|
||||
clearDrawListShadow();
|
||||
|
||||
// Number of blocks currently loaded by the client
|
||||
u32 blocks_loaded = 0;
|
||||
|
|
|
@ -89,12 +89,20 @@ public:
|
|||
|
||||
void getBlocksInViewRange(v3s16 cam_pos_nodes,
|
||||
v3s16 *p_blocks_min, v3s16 *p_blocks_max, float range=-1.0f);
|
||||
|
||||
void updateDrawList();
|
||||
// @brief Calculate statistics about the map and keep the blocks alive
|
||||
/// @brief clears m_drawlist and m_keeplist
|
||||
void clearDrawList();
|
||||
|
||||
/// @brief Calculate statistics about the map and keep the blocks alive
|
||||
void touchMapBlocks();
|
||||
|
||||
void updateDrawListShadow(v3f shadow_light_pos, v3f shadow_light_dir, float radius, float length);
|
||||
void clearDrawListShadow();
|
||||
|
||||
// Returns true if draw list needs updating before drawing the next frame.
|
||||
bool needsUpdateDrawList() { return m_needs_update_drawlist; }
|
||||
|
||||
void renderMap(video::IVideoDriver* driver, s32 pass);
|
||||
|
||||
void renderMapShadows(video::IVideoDriver *driver,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue