diff options
Diffstat (limited to 'src/client/clientmap.cpp')
-rw-r--r-- | src/client/clientmap.cpp | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/src/client/clientmap.cpp b/src/client/clientmap.cpp index 34d99e07d..146531d8b 100644 --- a/src/client/clientmap.cpp +++ b/src/client/clientmap.cpp @@ -298,6 +298,8 @@ void ClientMap::updateDrawList() blocks_to_consider.push(camera_block); blocks_seen.getChunk(camera_block).getBits(camera_block) = 0x07; // mark all sides as visible + std::set<v3s16> shortlist; + // Recursively walk the space and pick mapblocks for drawing while (blocks_to_consider.size() > 0) { @@ -369,11 +371,13 @@ void ClientMap::updateDrawList() continue; } - // The block is visible, add to the draw list - if (mesh) { - // Add to set + // Block meshes are stored in blocks where all coordinates are even (lowest bit set to 0) + // Add them to the de-dup set. + 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. + if (block && m_drawlist.emplace(block_coord, block).second) { + // only grab the ref if the block exists and was not in the list block->refGrab(); - m_drawlist[block_coord] = block; } // Decide which sides to traverse next or to block away @@ -474,6 +478,16 @@ void ClientMap::updateDrawList() } } + g_profiler->avg("MapBlocks shortlist [#]", shortlist.size()); + + for (auto pos : shortlist) { + MapBlock * block = getBlockNoCreateNoEx(pos); + if (block && m_drawlist.emplace(pos, block).second) { + // only grab the ref if the block exists and was not in the list + block->refGrab(); + } + } + g_profiler->avg("MapBlocks occlusion culled [#]", blocks_occlusion_culled); g_profiler->avg("MapBlocks sides skipped [#]", sides_skipped); g_profiler->avg("MapBlocks examined [#]", blocks_visited); @@ -597,7 +611,11 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass) MapBlock *block = i.second; MapBlockMesh *block_mesh = block->mesh; - // If the mesh of the block happened to get deleted, ignore it + // Meshes are only stored every 8-th block (where all coordinates are even), + // 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) continue; @@ -720,7 +738,7 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass) material.TextureLayer[ShadowRenderer::TEXTURE_LAYER_SHADOW].Texture = nullptr; } - v3f block_wpos = intToFloat(descriptor.m_pos * MAP_BLOCKSIZE, BS); + v3f block_wpos = intToFloat(descriptor.m_pos / 8 * 8 * MAP_BLOCKSIZE, BS); m.setTranslation(block_wpos - offset); driver->setTransform(video::ETS_WORLD, m); @@ -1046,7 +1064,7 @@ void ClientMap::renderMapShadows(video::IVideoDriver *driver, ++material_swaps; } - v3f block_wpos = intToFloat(descriptor.m_pos * MAP_BLOCKSIZE, BS); + v3f block_wpos = intToFloat(descriptor.m_pos / 8 * 8 * MAP_BLOCKSIZE, BS); m.setTranslation(block_wpos - offset); driver->setTransform(video::ETS_WORLD, m); @@ -1133,6 +1151,11 @@ void ClientMap::updateDrawListShadow(v3f shadow_light_pos, v3f shadow_light_dir, g_profiler->avg("SHADOW MapBlocks loaded [#]", blocks_loaded); } +void ClientMap::reportMetrics(u64 save_time_us, u32 saved_blocks, u32 all_blocks) +{ + g_profiler->avg("CM::reportMetrics loaded blocks [#]", all_blocks); +} + void ClientMap::updateTransparentMeshBuffers() { ScopeProfiler sp(g_profiler, "CM::updateTransparentMeshBuffers", SPT_AVG); |