Pull occlusion check out of loop, and minor code cleanups.
authorLars Hofhansl <larsh@apache.org>
Sat, 31 Dec 2016 20:40:31 +0000 (12:40 -0800)
committerNer'zhul <nerzhul@users.noreply.github.com>
Tue, 3 Jan 2017 07:14:58 +0000 (08:14 +0100)
src/clientmap.cpp

index 27f9dea38b92b6120ffec5f4df17d1a3c005c968..7d76e6e8bff4596493fb3ade62fc4371c6c2c490 100644 (file)
@@ -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<v2s16, MapSector*>::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;