forked from Mirrorlandia_minetest/minetest
Separate drawlist from non-rendered blocks. (#13176)
This commit is contained in:
parent
8bbb673c0b
commit
56d2567b5d
@ -257,6 +257,11 @@ void ClientMap::updateDrawList()
|
|||||||
}
|
}
|
||||||
m_drawlist.clear();
|
m_drawlist.clear();
|
||||||
|
|
||||||
|
for (auto &block : m_keeplist) {
|
||||||
|
block->refDrop();
|
||||||
|
}
|
||||||
|
m_keeplist.clear();
|
||||||
|
|
||||||
v3s16 cam_pos_nodes = floatToInt(m_camera_position, BS);
|
v3s16 cam_pos_nodes = floatToInt(m_camera_position, BS);
|
||||||
|
|
||||||
v3s16 p_blocks_min;
|
v3s16 p_blocks_min;
|
||||||
@ -374,9 +379,9 @@ void ClientMap::updateDrawList()
|
|||||||
// Block meshes are stored in blocks where all coordinates are even (lowest bit set to 0)
|
// Block meshes are stored in blocks where all coordinates are even (lowest bit set to 0)
|
||||||
// Add them to the de-dup set.
|
// Add them to the de-dup set.
|
||||||
shortlist.emplace(block_coord.X & ~1, block_coord.Y & ~1, block_coord.Z & ~1);
|
shortlist.emplace(block_coord.X & ~1, block_coord.Y & ~1, block_coord.Z & ~1);
|
||||||
// All other blocks we can grab and add to the drawlist right away.
|
// All other blocks we can grab and add to the keeplist right away.
|
||||||
if (block && m_drawlist.emplace(block_coord, block).second) {
|
if (block) {
|
||||||
// only grab the ref if the block exists and was not in the list
|
m_keeplist.push_back(block);
|
||||||
block->refGrab();
|
block->refGrab();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,11 +485,12 @@ void ClientMap::updateDrawList()
|
|||||||
|
|
||||||
g_profiler->avg("MapBlocks shortlist [#]", shortlist.size());
|
g_profiler->avg("MapBlocks shortlist [#]", shortlist.size());
|
||||||
|
|
||||||
|
assert(m_drawlist.empty());
|
||||||
for (auto pos : shortlist) {
|
for (auto pos : shortlist) {
|
||||||
MapBlock * block = getBlockNoCreateNoEx(pos);
|
MapBlock * block = getBlockNoCreateNoEx(pos);
|
||||||
if (block && m_drawlist.emplace(pos, block).second) {
|
if (block) {
|
||||||
// only grab the ref if the block exists and was not in the list
|
|
||||||
block->refGrab();
|
block->refGrab();
|
||||||
|
m_drawlist.emplace(pos, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -611,11 +617,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
|
|||||||
MapBlock *block = i.second;
|
MapBlock *block = i.second;
|
||||||
MapBlockMesh *block_mesh = block->mesh;
|
MapBlockMesh *block_mesh = block->mesh;
|
||||||
|
|
||||||
// Meshes are only stored every 8-th block (where all coordinates are even),
|
// If the mesh of the block happened to get deleted, ignore it
|
||||||
// but we keep all the visible blocks in the draw list to prevent client
|
|
||||||
// from dropping them.
|
|
||||||
// On top of that, in some cases block mesh can be removed
|
|
||||||
// before the block is removed from the draw list.
|
|
||||||
if (!block_mesh)
|
if (!block_mesh)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -1138,9 +1140,8 @@ void ClientMap::updateDrawListShadow(v3f shadow_light_pos, v3f shadow_light_dir,
|
|||||||
block->resetUsageTimer();
|
block->resetUsageTimer();
|
||||||
|
|
||||||
// Add to set
|
// Add to set
|
||||||
if (m_drawlist_shadow.find(block->getPos()) == m_drawlist_shadow.end()) {
|
if (m_drawlist_shadow.emplace(block->getPos(), block).second) {
|
||||||
block->refGrab();
|
block->refGrab();
|
||||||
m_drawlist_shadow[block->getPos()] = block;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -203,6 +203,7 @@ private:
|
|||||||
bool m_needs_update_transparent_meshes = true;
|
bool m_needs_update_transparent_meshes = true;
|
||||||
|
|
||||||
std::map<v3s16, MapBlock*, MapBlockComparer> m_drawlist;
|
std::map<v3s16, MapBlock*, MapBlockComparer> m_drawlist;
|
||||||
|
std::vector<MapBlock*> m_keeplist;
|
||||||
std::map<v3s16, MapBlock*> m_drawlist_shadow;
|
std::map<v3s16, MapBlock*> m_drawlist_shadow;
|
||||||
bool m_needs_update_drawlist;
|
bool m_needs_update_drawlist;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user