mirror of
https://github.com/moparisthebest/minetest
synced 2024-12-23 16:08:51 -05:00
Do post-mapgen lighting using the VoxelManipulator-based functions (causes glitches currently)
This commit is contained in:
parent
0f3c2f6541
commit
8cb7badd63
11
src/map.cpp
11
src/map.cpp
@ -2076,10 +2076,13 @@ void ServerMap::initBlockMake(mapgen::BlockMakeData *data, v3s16 blockpos)
|
|||||||
<<"("<<blockpos.X<<","<<blockpos.Y<<","<<blockpos.Z<<")"
|
<<"("<<blockpos.X<<","<<blockpos.Y<<","<<blockpos.Z<<")"
|
||||||
<<std::endl;
|
<<std::endl;
|
||||||
|
|
||||||
s16 chunksize = 2;
|
s16 chunksize = 3;
|
||||||
v3s16 blockpos_div = getContainerPos(blockpos, chunksize);
|
v3s16 chunk_offset(-1,-1,-1);
|
||||||
|
v3s16 blockpos_div = getContainerPos(blockpos - chunk_offset, chunksize);
|
||||||
v3s16 blockpos_min = blockpos_div * chunksize;
|
v3s16 blockpos_min = blockpos_div * chunksize;
|
||||||
v3s16 blockpos_max = blockpos_div * chunksize + v3s16(1,1,1)*(chunksize-1);
|
v3s16 blockpos_max = blockpos_div * chunksize + v3s16(1,1,1)*(chunksize-1);
|
||||||
|
blockpos_min += chunk_offset;
|
||||||
|
blockpos_max += chunk_offset;
|
||||||
|
|
||||||
// Do nothing if not inside limits (+-1 because of neighbors)
|
// Do nothing if not inside limits (+-1 because of neighbors)
|
||||||
if(blockpos_over_limit(blockpos_min - v3s16(1,1,1)) ||
|
if(blockpos_over_limit(blockpos_min - v3s16(1,1,1)) ||
|
||||||
@ -2223,6 +2226,7 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data,
|
|||||||
Update lighting
|
Update lighting
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
TimeTaker t("finishBlockMake lighting update");
|
TimeTaker t("finishBlockMake lighting update");
|
||||||
|
|
||||||
core::map<v3s16, MapBlock*> lighting_update_blocks;
|
core::map<v3s16, MapBlock*> lighting_update_blocks;
|
||||||
@ -2239,6 +2243,7 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateLighting(lighting_update_blocks, changed_blocks);
|
updateLighting(lighting_update_blocks, changed_blocks);
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Set lighting to non-expired state in all of them.
|
Set lighting to non-expired state in all of them.
|
||||||
@ -2253,8 +2258,10 @@ MapBlock* ServerMap::finishBlockMake(mapgen::BlockMakeData *data,
|
|||||||
getBlockNoCreateNoEx(p)->setLightingExpired(false);
|
getBlockNoCreateNoEx(p)->setLightingExpired(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
if(enable_mapgen_debug_info == false)
|
if(enable_mapgen_debug_info == false)
|
||||||
t.stop(true); // Hide output
|
t.stop(true); // Hide output
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Center blocks
|
// Center blocks
|
||||||
|
@ -27,6 +27,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "nodedef.h"
|
#include "nodedef.h"
|
||||||
#include "content_mapnode.h" // For content_mapnode_get_new_name
|
#include "content_mapnode.h" // For content_mapnode_get_new_name
|
||||||
#include "voxelalgorithms.h"
|
#include "voxelalgorithms.h"
|
||||||
|
#include "profiler.h"
|
||||||
|
#include "main.h" // For g_profiler
|
||||||
|
|
||||||
namespace mapgen
|
namespace mapgen
|
||||||
{
|
{
|
||||||
@ -2339,7 +2341,33 @@ void make_block(BlockMakeData *data)
|
|||||||
/*
|
/*
|
||||||
Calculate lighting
|
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<v3s16, bool> light_sources;
|
||||||
|
core::map<v3s16, u8> 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():
|
BlockMakeData::BlockMakeData():
|
||||||
|
Loading…
Reference in New Issue
Block a user