Increase performance of updateDrawListPerf by 25%. Delete an unused member

This commit is contained in:
gregorycu 2015-11-08 17:56:32 +11:00 committed by BlockMen
parent 7461af3df5
commit 303c43624f
2 changed files with 9 additions and 26 deletions

View File

@ -151,11 +151,11 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver)
INodeDefManager *nodemgr = m_gamedef->ndef();
for(std::map<v3s16, MapBlock*>::iterator
for (std::vector<MapBlock*>::iterator
i = m_drawlist.begin();
i != m_drawlist.end(); ++i)
{
MapBlock *block = i->second;
MapBlock *block = *i;
block->refDrop();
}
m_drawlist.clear();
@ -205,6 +205,8 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver)
// Distance to farthest drawn block
float farthest_drawn = 0;
bool free_move = g_settings->getBool("free_move");
for(std::map<v2s16, MapSector*>::iterator
si = m_sectors.begin();
si != m_sectors.end(); ++si)
@ -281,7 +283,7 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver)
// No occlusion culling when free_move is on and camera is
// inside ground
bool occlusion_culling_enabled = true;
if(g_settings->getBool("free_move")){
if (free_move){
MapNode n = getNodeNoEx(cam_pos_nodes);
if(n.getContent() == CONTENT_IGNORE ||
nodemgr->get(n).solidness == 2)
@ -335,7 +337,7 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver)
// Add to set
block->refGrab();
m_drawlist[block->getPos()] = block;
m_drawlist.push_back(block);
sector_blocks_drawn++;
blocks_drawn++;
@ -343,9 +345,6 @@ void ClientMap::updateDrawList(video::IVideoDriver* driver)
farthest_drawn = d/BS;
} // foreach sectorblocks
if(sector_blocks_drawn != 0)
m_last_drawn_sectors.insert(sp);
}
m_control.blocks_would_have_drawn = blocks_would_have_drawn;
@ -413,14 +412,6 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
else
prefix = "CM: transparent: ";
/*
This is called two times per frame, reset on the non-transparent one
*/
if(pass == scene::ESNRP_SOLID)
{
m_last_drawn_sectors.clear();
}
/*
Get time for measuring timeout.
@ -487,11 +478,11 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
MeshBufListList drawbufs;
for(std::map<v3s16, MapBlock*>::iterator
for(std::vector<MapBlock*>::iterator
i = m_drawlist.begin();
i != m_drawlist.end(); ++i)
{
MapBlock *block = i->second;
MapBlock *block = *i;
// If the mesh of the block happened to get deleted, ignore it
if(block->mesh == NULL)

View File

@ -135,12 +135,6 @@ public:
// For debug printing
virtual void PrintInfo(std::ostream &out);
// Check if sector was drawn on last render()
bool sectorWasDrawn(v2s16 p)
{
return (m_last_drawn_sectors.find(p) != m_last_drawn_sectors.end());
}
private:
Client *m_client;
@ -154,9 +148,7 @@ private:
v3s16 m_camera_offset;
Mutex m_camera_mutex;
std::map<v3s16, MapBlock*> m_drawlist;
std::set<v2s16> m_last_drawn_sectors;
std::vector<MapBlock*> m_drawlist;
bool m_cache_trilinear_filter;
bool m_cache_bilinear_filter;