summaryrefslogtreecommitdiff
path: root/src/mapnode.cpp
diff options
context:
space:
mode:
authorDániel Juhász <juhdanad@gmail.com>2016-10-20 21:41:38 +0200
committerNer'zhul <nerzhul@users.noreply.github.com>2016-10-27 08:04:42 +0200
commitc071efaa43ad3dcba7d60a7a67e942aae2a7dc83 (patch)
tree005ca91912ba59cbe5b676b8067d82a5483ed1ce /src/mapnode.cpp
parent1fd9a07497c45364ed8396653501c6be2a2e2ade (diff)
downloadminetest-c071efaa43ad3dcba7d60a7a67e942aae2a7dc83.tar.gz
minetest-c071efaa43ad3dcba7d60a7a67e942aae2a7dc83.tar.bz2
minetest-c071efaa43ad3dcba7d60a7a67e942aae2a7dc83.zip
Improved lighting
This commit rewrites the procedure that is responsible for light updating. this commit -provides iterative solutions for unlighting and light spreading -introduces a new priority queue-like container for the iteration -creates per-node MapBlock caching to reduce retrieving MapBlocks from the map -calculates with map block positions and in-block relative node coordinates -skips light updating if it is not necessary since the node's new light will be the same as its old light was
Diffstat (limited to 'src/mapnode.cpp')
-rw-r--r--src/mapnode.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/mapnode.cpp b/src/mapnode.cpp
index eba47446d..5efebf3d8 100644
--- a/src/mapnode.cpp
+++ b/src/mapnode.cpp
@@ -54,10 +54,10 @@ MapNode::MapNode(INodeDefManager *ndef, const std::string &name,
param2 = a_param2;
}
-void MapNode::setLight(enum LightBank bank, u8 a_light, INodeDefManager *nodemgr)
+void MapNode::setLight(enum LightBank bank, u8 a_light, const ContentFeatures &f)
{
// If node doesn't contain light data, ignore this
- if(nodemgr->get(*this).param_type != CPT_LIGHT)
+ if(f.param_type != CPT_LIGHT)
return;
if(bank == LIGHTBANK_DAY)
{
@@ -73,6 +73,11 @@ void MapNode::setLight(enum LightBank bank, u8 a_light, INodeDefManager *nodemgr
assert("Invalid light bank" == NULL);
}
+void MapNode::setLight(enum LightBank bank, u8 a_light, INodeDefManager *nodemgr)
+{
+ setLight(bank, a_light, nodemgr->get(*this));
+}
+
bool MapNode::isLightDayNightEq(INodeDefManager *nodemgr) const
{
const ContentFeatures &f = nodemgr->get(*this);
@@ -103,6 +108,13 @@ u8 MapNode::getLight(enum LightBank bank, INodeDefManager *nodemgr) const
return MYMAX(f.light_source, light);
}
+u8 MapNode::getLightRaw(enum LightBank bank, const ContentFeatures &f) const
+{
+ if(f.param_type == CPT_LIGHT)
+ return bank == LIGHTBANK_DAY ? param1 & 0x0f : (param1 >> 4) & 0x0f;
+ return 0;
+}
+
u8 MapNode::getLightNoChecks(enum LightBank bank, const ContentFeatures *f) const
{
return MYMAX(f->light_source,