From a32706bc2699f5079d7541d0f19e8f470b416704 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Fri, 27 Jan 2012 04:02:42 +0200 Subject: Post-mapgen lighting optimization --- src/map.cpp | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/map.cpp b/src/map.cpp index d6b33ed66..dce3bdc09 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -727,10 +727,16 @@ void Map::updateLighting(enum LightBank bank, n.setLight(bank, 0, nodemgr); block->setNode(p, n); + // If node sources light, add to list + u8 source = nodemgr->get(n).light_source; + if(source != 0) + light_sources[p + posnodes] = true; + // Collect borders for unlighting - if(x==0 || x == MAP_BLOCKSIZE-1 + if((x==0 || x == MAP_BLOCKSIZE-1 || y==0 || y == MAP_BLOCKSIZE-1 || z==0 || z == MAP_BLOCKSIZE-1) + && oldlight != 0) { v3s16 p_map = p + posnodes; unlight_from.insert(p_map, oldlight); @@ -806,38 +812,43 @@ void Map::updateLighting(enum LightBank bank, } #endif -#if 0 +#if 1 { - TimeTaker timer("unspreadLight"); + //TimeTaker timer("unspreadLight"); unspreadLight(bank, unlight_from, light_sources, modified_blocks); } - if(debug) + /*if(debug) { u32 diff = modified_blocks.size() - count_was; count_was = modified_blocks.size(); infostream<<"unspreadLight modified "<::Iterator i; i = blocks_to_update.getIterator(); for(; i.atEnd() == false; i++) @@ -871,22 +882,24 @@ void Map::updateLighting(enum LightBank bank, // Lighting of block will be updated completely block->setLightingExpired(false); } + } { - //TimeTaker timer("unSpreadLight"); + TimeTaker timer("unSpreadLight"); vmanip.unspreadLight(bank, unlight_from, light_sources, nodemgr); } { - //TimeTaker timer("spreadLight"); + TimeTaker timer("spreadLight"); vmanip.spreadLight(bank, light_sources, nodemgr); } { - //TimeTaker timer("blitBack"); + TimeTaker timer("blitBack"); vmanip.blitBack(modified_blocks); } /*infostream<<"emerge_time="<