diff options
author | Vitaliy <silverunicorn2011@yandex.ru> | 2018-03-03 12:58:45 +0300 |
---|---|---|
committer | SmallJoker <SmallJoker@users.noreply.github.com> | 2018-03-03 10:58:45 +0100 |
commit | f5fd4a0af1fef2e9cd3f7f368884349013a06dcc (patch) | |
tree | bb6a4ff4e7973c8c04b273e453fac57a94ce04fe /src | |
parent | e7f16119913f7b2c98059398085d410684c9d8c0 (diff) | |
download | minetest-f5fd4a0af1fef2e9cd3f7f368884349013a06dcc.tar.gz minetest-f5fd4a0af1fef2e9cd3f7f368884349013a06dcc.tar.bz2 minetest-f5fd4a0af1fef2e9cd3f7f368884349013a06dcc.zip |
Cleanup in flat lighting (#7051)
Diffstat (limited to 'src')
-rw-r--r-- | src/light.h | 30 | ||||
-rw-r--r-- | src/mapblock_mesh.cpp | 14 |
2 files changed, 2 insertions, 42 deletions
diff --git a/src/light.h b/src/light.h index f8c4b83c3..203bd851e 100644 --- a/src/light.h +++ b/src/light.h @@ -35,36 +35,6 @@ with this program; if not, write to the Free Software Foundation, Inc., // This brightness is reserved for sunlight #define LIGHT_SUN 15 -inline u8 diminish_light(u8 light) -{ - if (light == 0) - return 0; - if (light >= LIGHT_MAX) - return LIGHT_MAX - 1; - - return light - 1; -} - -inline u8 diminish_light(u8 light, u8 distance) -{ - if (distance >= light) - return 0; - return light - distance; -} - -inline u8 undiminish_light(u8 light) -{ - assert(light <= LIGHT_SUN); - // We don't know if light should undiminish from this particular 0. - // Thus, keep it at 0. - if (light == 0) - return 0; - if (light >= LIGHT_MAX) - return light; - - return light + 1; -} - #ifndef SERVER /** diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp index 48171c84c..bdf791c0b 100644 --- a/src/mapblock_mesh.cpp +++ b/src/mapblock_mesh.cpp @@ -130,18 +130,8 @@ static u8 getInteriorLight(enum LightBank bank, MapNode n, s32 increment, const NodeDefManager *ndef) { u8 light = n.getLight(bank, ndef); - - while(increment > 0) - { - light = undiminish_light(light); - --increment; - } - while(increment < 0) - { - light = diminish_light(light); - ++increment; - } - + if (light > 0) + light = rangelim(light + increment, 0, LIGHT_SUN); return decode_light(light); } |