From f46509d5e2c681b6da2abdeb27779be3c36a6916 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Mon, 5 Oct 2020 09:07:33 +0200 Subject: Remove unused functions reported by cppcheck (#10463) Run unused functions reported by cppcheck This change removes a few (but not all) unused functions. Some unused helper functions were not removed due to their complexity and potential of future use. --- src/client/clientmap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/client/clientmap.cpp') diff --git a/src/client/clientmap.cpp b/src/client/clientmap.cpp index 3e4ab2e94..3124313e7 100644 --- a/src/client/clientmap.cpp +++ b/src/client/clientmap.cpp @@ -36,7 +36,7 @@ ClientMap::ClientMap( MapDrawControl &control, s32 id ): - Map(dout_client, client), + Map(client), scene::ISceneNode(RenderingEngine::get_scene_manager()->getRootSceneNode(), RenderingEngine::get_scene_manager(), id), m_client(client), -- cgit v1.2.3 From 521a04222a71325ef217d1214febf5591919e169 Mon Sep 17 00:00:00 2001 From: Lars Date: Mon, 12 Oct 2020 19:47:04 -0700 Subject: Avoid drawing invisible blocks on the client. --- src/client/clientmap.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'src/client/clientmap.cpp') diff --git a/src/client/clientmap.cpp b/src/client/clientmap.cpp index 3124313e7..d372a8e46 100644 --- a/src/client/clientmap.cpp +++ b/src/client/clientmap.cpp @@ -124,12 +124,6 @@ void ClientMap::updateDrawList() v3f camera_position = m_camera_position; v3f camera_direction = m_camera_direction; - f32 camera_fov = m_camera_fov; - - // Use a higher fov to accomodate faster camera movements. - // Blocks are cropped better when they are drawn. - // Or maybe they aren't? Well whatever. - camera_fov *= 1.2; v3s16 cam_pos_nodes = floatToInt(camera_position, BS); v3s16 p_blocks_min; @@ -190,7 +184,7 @@ void ClientMap::updateDrawList() float d = 0.0; if (!isBlockInSight(block->getPos(), camera_position, - camera_direction, camera_fov, range, &d)) + camera_direction, m_camera_fov, range, &d)) continue; -- cgit v1.2.3 From b826e3973065a0bb81269c8decb5a33073508164 Mon Sep 17 00:00:00 2001 From: Lars Date: Sun, 18 Oct 2020 16:38:51 -0700 Subject: Minor clientmap improvements. - Avoid calculating isBlockInSight for blocks without meshes. - Add metric for how many blocks the client has currently loaded. - Make some variables constant. --- src/client/clientmap.cpp | 36 +++++++++++++++++++----------------- src/mapsector.h | 1 + 2 files changed, 20 insertions(+), 17 deletions(-) (limited to 'src/client/clientmap.cpp') diff --git a/src/client/clientmap.cpp b/src/client/clientmap.cpp index d372a8e46..c8561def6 100644 --- a/src/client/clientmap.cpp +++ b/src/client/clientmap.cpp @@ -122,14 +122,17 @@ void ClientMap::updateDrawList() } m_drawlist.clear(); - v3f camera_position = m_camera_position; - v3f camera_direction = m_camera_direction; + const v3f camera_position = m_camera_position; + const v3f camera_direction = m_camera_direction; + const f32 camera_fov = m_camera_fov; v3s16 cam_pos_nodes = floatToInt(camera_position, BS); v3s16 p_blocks_min; v3s16 p_blocks_max; getBlocksInViewRange(cam_pos_nodes, &p_blocks_min, &p_blocks_max); + // Number of blocks currently loaded by the client + u32 blocks_loaded = 0; // Number of blocks with mesh in rendering range u32 blocks_in_range_with_mesh = 0; // Number of blocks occlusion culled @@ -154,6 +157,7 @@ void ClientMap::updateDrawList() MapSector *sector = sector_it.second; v2s16 sp = sector->getPos(); + blocks_loaded += sector->size(); if (!m_control.range_all) { if (sp.X < p_blocks_min.X || sp.X > p_blocks_max.X || sp.Y < p_blocks_min.Z || sp.Y > p_blocks_max.Z) @@ -175,8 +179,12 @@ void ClientMap::updateDrawList() if not seen on display */ - if (block->mesh) + if (block->mesh) { block->mesh->updateCameraOffset(m_camera_offset); + } else { + // Ignore if mesh doesn't exist + continue; + } float range = 100000 * BS; if (!m_control.range_all) @@ -184,14 +192,7 @@ void ClientMap::updateDrawList() float d = 0.0; if (!isBlockInSight(block->getPos(), camera_position, - camera_direction, m_camera_fov, range, &d)) - continue; - - - /* - Ignore if mesh doesn't exist - */ - if (!block->mesh) + camera_direction, camera_fov, range, &d)) continue; blocks_in_range_with_mesh++; @@ -222,6 +223,7 @@ void ClientMap::updateDrawList() g_profiler->avg("MapBlock meshes in range [#]", blocks_in_range_with_mesh); g_profiler->avg("MapBlocks occlusion culled [#]", blocks_occlusion_culled); g_profiler->avg("MapBlocks drawn [#]", m_drawlist.size()); + g_profiler->avg("MapBlocks loaded [#]", blocks_loaded); } struct MeshBufList @@ -287,13 +289,13 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass) /* Get animation parameters */ - float animation_time = m_client->getAnimationTime(); - int crack = m_client->getCrackLevel(); - u32 daynight_ratio = m_client->getEnv().getDayNightRatio(); + const float animation_time = m_client->getAnimationTime(); + const int crack = m_client->getCrackLevel(); + const u32 daynight_ratio = m_client->getEnv().getDayNightRatio(); - v3f camera_position = m_camera_position; - v3f camera_direction = m_camera_direction; - f32 camera_fov = m_camera_fov; + const v3f camera_position = m_camera_position; + const v3f camera_direction = m_camera_direction; + const f32 camera_fov = m_camera_fov; /* Get all blocks and draw all visible ones diff --git a/src/mapsector.h b/src/mapsector.h index dede364f6..ffd4cdd1d 100644 --- a/src/mapsector.h +++ b/src/mapsector.h @@ -62,6 +62,7 @@ public: bool empty() const { return m_blocks.empty(); } + int size() const { return m_blocks.size(); } protected: // The pile of MapBlocks -- cgit v1.2.3 From 8dc70ebb936277f740dffe9a11b5ee0fecc9de8e Mon Sep 17 00:00:00 2001 From: Lars Date: Tue, 24 Nov 2020 09:23:18 -0800 Subject: Fix camera panning glitches (partially revert 10489.) --- src/client/clientmap.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/client/clientmap.cpp') diff --git a/src/client/clientmap.cpp b/src/client/clientmap.cpp index c8561def6..09072858a 100644 --- a/src/client/clientmap.cpp +++ b/src/client/clientmap.cpp @@ -124,7 +124,10 @@ void ClientMap::updateDrawList() const v3f camera_position = m_camera_position; const v3f camera_direction = m_camera_direction; - const f32 camera_fov = m_camera_fov; + + // Use a higher fov to accomodate faster camera movements. + // Blocks are cropped better when they are drawn. + const f32 camera_fov = m_camera_fov * 1.1f; v3s16 cam_pos_nodes = floatToInt(camera_position, BS); v3s16 p_blocks_min; -- cgit v1.2.3