mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
Faster lighting at map generation time
This commit is contained in:
parent
87554408ca
commit
3909e712a0
8 changed files with 605 additions and 33 deletions
|
@ -168,7 +168,7 @@ void * EmergeThread::Thread()
|
|||
changed_blocks,
|
||||
lighting_invalidated_blocks);
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
/*
|
||||
EXPERIMENTAL: Create a few other blocks too
|
||||
*/
|
||||
|
@ -184,6 +184,19 @@ void * EmergeThread::Thread()
|
|||
only_from_disk,
|
||||
changed_blocks,
|
||||
lighting_invalidated_blocks);
|
||||
#if 0
|
||||
map.emergeBlock(
|
||||
p + v3s16(0,2,0),
|
||||
only_from_disk,
|
||||
changed_blocks,
|
||||
lighting_invalidated_blocks);
|
||||
|
||||
map.emergeBlock(
|
||||
p + v3s16(0,-2,0),
|
||||
only_from_disk,
|
||||
changed_blocks,
|
||||
lighting_invalidated_blocks);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -216,23 +229,6 @@ void * EmergeThread::Thread()
|
|||
dout_server<<std::endl;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
Update water pressure
|
||||
*/
|
||||
|
||||
m_server->UpdateBlockWaterPressure(block, modified_blocks);
|
||||
|
||||
for(core::map<v3s16, MapBlock*>::Iterator i = changed_blocks.getIterator();
|
||||
i.atEnd() == false; i++)
|
||||
{
|
||||
MapBlock *block = i.getNode()->getValue();
|
||||
m_server->UpdateBlockWaterPressure(block, modified_blocks);
|
||||
//v3s16 p = i.getNode()->getKey();
|
||||
//m_server->UpdateBlockWaterPressure(p, modified_blocks);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
Collect a list of blocks that have been modified in
|
||||
addition to the fetched one.
|
||||
|
@ -249,7 +245,7 @@ void * EmergeThread::Thread()
|
|||
/*dstream<<"lighting "<<lighting_invalidated_blocks.size()
|
||||
<<" blocks"<<std::endl;*/
|
||||
|
||||
//TimeTaker timer("** updateLighting", g_device);
|
||||
//TimeTaker timer("** updateLighting");
|
||||
|
||||
// Update lighting without locking the environment mutex,
|
||||
// add modified blocks to changed blocks
|
||||
|
@ -497,7 +493,8 @@ void RemoteClient::GetNextBlocks(Server *server, float dtime,
|
|||
|| p.Z < -MAP_GENERATION_LIMIT / MAP_BLOCKSIZE
|
||||
|| p.Z > MAP_GENERATION_LIMIT / MAP_BLOCKSIZE)
|
||||
continue;
|
||||
|
||||
|
||||
// If this is true, inexistent block will be made from scratch
|
||||
bool generate = d <= d_max_gen;
|
||||
|
||||
if(haxmode)
|
||||
|
@ -513,6 +510,35 @@ void RemoteClient::GetNextBlocks(Server *server, float dtime,
|
|||
generate = false;
|
||||
}
|
||||
|
||||
/*
|
||||
If block is far away, don't generate it unless it is
|
||||
near ground level
|
||||
*/
|
||||
if(d > 4)
|
||||
{
|
||||
v2s16 p2d(p.X, p.Z);
|
||||
MapSector *sector = NULL;
|
||||
try
|
||||
{
|
||||
sector = server->m_env.getMap().getSectorNoGenerate(p2d);
|
||||
}
|
||||
catch(InvalidPositionException &e)
|
||||
{
|
||||
}
|
||||
|
||||
if(sector != NULL)
|
||||
{
|
||||
// Get center ground height in nodes
|
||||
f32 gh = sector->getGroundHeight(
|
||||
v2s16(MAP_BLOCKSIZE/2, MAP_BLOCKSIZE/2));
|
||||
// Block center y in nodes
|
||||
f32 y = (f32)(p.Y * MAP_BLOCKSIZE + MAP_BLOCKSIZE/2);
|
||||
// If differs a lot, don't generate
|
||||
if(fabs(gh - y) > MAP_BLOCKSIZE*2)
|
||||
generate = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Don't draw if not in sight
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue