From 8cb7badd632200e06004577f351b9c845c174e29 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Fri, 27 Jan 2012 14:10:10 +0200 Subject: [PATCH] Do post-mapgen lighting using the VoxelManipulator-based functions (causes glitches currently) --- src/map.cpp | 11 +++++++++-- src/mapgen.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/map.cpp b/src/map.cpp index 1ab2b32a..2625cbad 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2076,10 +2076,13 @@ void ServerMap::initBlockMake(mapgen::BlockMakeData *data, v3s16 blockpos) <<"("< lighting_update_blocks; @@ -2239,6 +2243,7 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data, } updateLighting(lighting_update_blocks, changed_blocks); +#endif /* Set lighting to non-expired state in all of them. @@ -2253,8 +2258,10 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data, getBlockNoCreateNoEx(p)->setLightingExpired(false); } +#if 0 if(enable_mapgen_debug_info == false) t.stop(true); // Hide output +#endif } // Center blocks diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 25fa427a..0ce211f3 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -27,6 +27,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "nodedef.h" #include "content_mapnode.h" // For content_mapnode_get_new_name #include "voxelalgorithms.h" +#include "profiler.h" +#include "main.h" // For g_profiler namespace mapgen { @@ -2339,7 +2341,33 @@ void make_block(BlockMakeData *data) /* Calculate lighting */ + { + ScopeProfiler sp(g_profiler, "EmergeThread: mapgen lighting update", + SPT_AVG); + VoxelArea a(node_min, node_max); + enum LightBank banks[2] = {LIGHTBANK_DAY, LIGHTBANK_NIGHT}; + for(int i=0; i<2; i++) + { + enum LightBank bank = banks[i]; + core::map light_sources; + core::map unlight_from; + + voxalgo::clearLightAndCollectSources(vmanip, a, bank, ndef, + light_sources, unlight_from); + + // TODO: Get this from elsewhere + bool inexistent_top_provides_sunlight = true; + voxalgo::SunlightPropagateResult res = voxalgo::propagateSunlight( + vmanip, a, inexistent_top_provides_sunlight, + light_sources, ndef); + // TODO: Do stuff according to bottom_sunlight_valid + + vmanip.unspreadLight(bank, unlight_from, light_sources, ndef); + + vmanip.spreadLight(bank, light_sources, ndef); + } + } } BlockMakeData::BlockMakeData():