From be39f61359ad63f2c6d4aea14c1dfd8357eee03f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Juh=C3=A1sz?= Date: Sun, 23 Oct 2016 17:51:13 +0200 Subject: Use node lighting for liquid spreading This commit modifies the liquid transforming procedure to light and unlight nodes instead of whole map blocks. --- src/map.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'src/map.cpp') diff --git a/src/map.cpp b/src/map.cpp index 1694582db..5a1611c89 100644 --- a/src/map.cpp +++ b/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 > oldnodes; + oldnodes.push_back(std::pair(p, oldnode)); + voxalgo::update_lighting_nodes(this, ndef, oldnodes, modified_blocks); for(std::map::iterator i = modified_blocks.begin(); @@ -1224,7 +1229,9 @@ void Map::transformLiquids(std::map &modified_blocks) std::deque must_reflow; // List of MapBlocks that will require a lighting update (due to lava) - std::map lighting_modified_blocks; + std::map lighting_modified_blocks2; + + std::vector > 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 &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 &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(p0, n00)); } /* @@ -1515,7 +1527,8 @@ void Map::transformLiquids(std::map &modified_blocks) for (std::deque::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); /* ---------------------------------------------------------------------- -- cgit v1.2.3