diff options
author | Craig Robbins <kde.psych@gmail.com> | 2015-02-07 17:52:56 +1000 |
---|---|---|
committer | Loic Blot <loic.blot@unix-experience.fr> | 2015-02-10 16:23:37 +0100 |
commit | caf8d2a9d16a313bbc86a27ad0642efc76852e9f (patch) | |
tree | 9787d5960dc11c3fbe37ab05efb103fcbb3dcddc /src/mapnode.cpp | |
parent | bb59a8543d44b566d8b39fd4727d552a8d4f3e90 (diff) | |
download | minetest-caf8d2a9d16a313bbc86a27ad0642efc76852e9f.tar.gz minetest-caf8d2a9d16a313bbc86a27ad0642efc76852e9f.tar.bz2 minetest-caf8d2a9d16a313bbc86a27ad0642efc76852e9f.zip |
Increase MapBlock::actuallyUpdateDayNightDiff() performance by 2-8x. ok @celeron55
Before patch, function consumes up to ~8% of the main server loop. After, ~0% (below level of 2 places of significance)
Diffstat (limited to 'src/mapnode.cpp')
-rw-r--r-- | src/mapnode.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/mapnode.cpp b/src/mapnode.cpp index 056b94054..388071a17 100644 --- a/src/mapnode.cpp +++ b/src/mapnode.cpp @@ -74,6 +74,22 @@ void MapNode::setLight(enum LightBank bank, u8 a_light, INodeDefManager *nodemgr assert(0); } +bool MapNode::isLightDayNightEq(INodeDefManager *nodemgr) const +{ + const ContentFeatures &f = nodemgr->get(*this); + bool isEqual; + + if (f.param_type == CPT_LIGHT) { + u8 day = MYMAX(f.light_source, param1 & 0x0f); + u8 night = MYMAX(f.light_source, (param1 >> 4) & 0x0f); + isEqual = day == night; + } else { + isEqual = true; + } + + return isEqual; +} + u8 MapNode::getLight(enum LightBank bank, INodeDefManager *nodemgr) const { // Select the brightest of [light source, propagated light] |