From 7387b190213996e453d0a7447027a71615034f5e Mon Sep 17 00:00:00 2001 From: Lars Hofhansl Date: Sat, 31 Dec 2016 12:40:31 -0800 Subject: [PATCH] Pull occlusion check out of loop, and minor code cleanups. --- src/clientmap.cpp | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/src/clientmap.cpp b/src/clientmap.cpp index 27f9dea38..7d76e6e8b 100644 --- a/src/clientmap.cpp +++ b/src/clientmap.cpp @@ -213,6 +213,16 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver) // Distance to farthest drawn block float farthest_drawn = 0; + // No occlusion culling when free_move is on and camera is + // inside ground + bool occlusion_culling_enabled = true; + if (g_settings->getBool("free_move")) { + MapNode n = getNodeNoEx(cam_pos_nodes); + if (n.getContent() == CONTENT_IGNORE || + nodemgr->get(n).solidness == 2) + occlusion_culling_enabled = false; + } + for (std::map::iterator si = m_sectors.begin(); si != m_sectors.end(); ++si) { MapSector *sector = si->second; @@ -254,39 +264,19 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver) camera_direction, camera_fov, range, &d)) continue; - // This is ugly (spherical distance limit?) - /*if(m_control.range_all == false && - d - 0.5*BS*MAP_BLOCKSIZE > range) - continue;*/ - blocks_in_range++; /* Ignore if mesh doesn't exist */ - { - //MutexAutoLock lock(block->mesh_mutex); - - if (block->mesh == NULL) { - blocks_in_range_without_mesh++; - continue; - } + if (block->mesh == NULL) { + blocks_in_range_without_mesh++; + continue; } /* Occlusion culling */ - - // No occlusion culling when free_move is on and camera is - // inside ground - bool occlusion_culling_enabled = true; - if (g_settings->getBool("free_move")) { - MapNode n = getNodeNoEx(cam_pos_nodes); - if (n.getContent() == CONTENT_IGNORE || - nodemgr->get(n).solidness == 2) - occlusion_culling_enabled = false; - } - v3s16 cpn = block->getPos() * MAP_BLOCKSIZE; cpn += v3s16(MAP_BLOCKSIZE / 2, MAP_BLOCKSIZE / 2, MAP_BLOCKSIZE / 2); float step = BS * 1; @@ -447,11 +437,6 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass) Get all blocks and draw all visible ones */ - 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); - u32 vertex_count = 0; u32 meshbuffer_count = 0; -- 2.25.1