summaryrefslogtreecommitdiff
path: root/src/map.cpp
diff options
context:
space:
mode:
authorDániel Juhász <juhdanad@gmail.com>2016-10-23 17:51:13 +0200
committerNer'zhul <nerzhul@users.noreply.github.com>2016-10-27 08:04:42 +0200
commitbe39f61359ad63f2c6d4aea14c1dfd8357eee03f (patch)
tree17209bda6ba8e178b37f55dc479a91d981609cd7 /src/map.cpp
parentc071efaa43ad3dcba7d60a7a67e942aae2a7dc83 (diff)
downloadminetest-be39f61359ad63f2c6d4aea14c1dfd8357eee03f.tar.gz
minetest-be39f61359ad63f2c6d4aea14c1dfd8357eee03f.tar.bz2
minetest-be39f61359ad63f2c6d4aea14c1dfd8357eee03f.zip
Use node lighting for liquid spreading
This commit modifies the liquid transforming procedure to light and unlight nodes instead of whole map blocks.
Diffstat (limited to 'src/map.cpp')
-rw-r--r--src/map.cpp23
1 files changed, 18 insertions, 5 deletions
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<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);
/* ----------------------------------------------------------------------