mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Use node lighting for liquid spreading
This commit modifies the liquid transforming procedure to light and unlight nodes instead of whole map blocks.
This commit is contained in:
parent
c071efaa43
commit
be39f61359
3 changed files with 145 additions and 122 deletions
23
src/map.cpp
23
src/map.cpp
|
@ -824,10 +824,15 @@ void Map::addNodeAndUpdate(v3s16 p, MapNode n,
|
|||
}
|
||||
|
||||
// Set the node on the map
|
||||
// Ignore light (because calling voxalgo::update_lighting_nodes)
|
||||
n.setLight(LIGHTBANK_DAY, 0, ndef);
|
||||
n.setLight(LIGHTBANK_NIGHT, 0, ndef);
|
||||
setNode(p, n);
|
||||
|
||||
// Update lighting
|
||||
voxalgo::update_lighting_node(this, ndef, p, oldnode, modified_blocks);
|
||||
std::vector<std::pair<v3s16, MapNode> > oldnodes;
|
||||
oldnodes.push_back(std::pair<v3s16, MapNode>(p, oldnode));
|
||||
voxalgo::update_lighting_nodes(this, ndef, oldnodes, modified_blocks);
|
||||
|
||||
for(std::map<v3s16, MapBlock*>::iterator
|
||||
i = modified_blocks.begin();
|
||||
|
@ -1224,7 +1229,9 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks)
|
|||
std::deque<v3s16> must_reflow;
|
||||
|
||||
// List of MapBlocks that will require a lighting update (due to lava)
|
||||
std::map<v3s16, MapBlock *> lighting_modified_blocks;
|
||||
std::map<v3s16, MapBlock *> lighting_modified_blocks2;
|
||||
|
||||
std::vector<std::pair<v3s16, MapNode> > changed_nodes;
|
||||
|
||||
u32 liquid_loop_max = g_settings->getS32("liquid_loop_max");
|
||||
u32 loop_max = liquid_loop_max;
|
||||
|
@ -1457,6 +1464,10 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks)
|
|||
}
|
||||
n0.setContent(new_node_content);
|
||||
|
||||
// Ignore light (because calling voxalgo::update_lighting_nodes)
|
||||
n0.setLight(LIGHTBANK_DAY, 0, nodemgr);
|
||||
n0.setLight(LIGHTBANK_NIGHT, 0, nodemgr);
|
||||
|
||||
// Find out whether there is a suspect for this action
|
||||
std::string suspect;
|
||||
if (m_gamedef->rollback())
|
||||
|
@ -1484,9 +1495,10 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks)
|
|||
if (block != NULL) {
|
||||
modified_blocks[blockpos] = block;
|
||||
// If new or old node emits light, MapBlock requires lighting update
|
||||
if (nodemgr->get(n0).light_source != 0 ||
|
||||
/*if (nodemgr->get(n0).light_source != 0 ||
|
||||
nodemgr->get(n00).light_source != 0)
|
||||
lighting_modified_blocks[block->getPos()] = block;
|
||||
lighting_modified_blocks[block->getPos()] = block;*/
|
||||
changed_nodes.push_back(std::pair<v3s16, MapNode>(p0, n00));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1515,7 +1527,8 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> &modified_blocks)
|
|||
for (std::deque<v3s16>::iterator iter = must_reflow.begin(); iter != must_reflow.end(); ++iter)
|
||||
m_transforming_liquid.push_back(*iter);
|
||||
|
||||
updateLighting(lighting_modified_blocks, modified_blocks);
|
||||
//updateLighting(lighting_modified_blocks, modified_blocks);
|
||||
voxalgo::update_lighting_nodes(this, nodemgr, changed_nodes, modified_blocks);
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue