Cleanup in flat lighting (#7051)
authorVitaliy <silverunicorn2011@yandex.ru>
Sat, 3 Mar 2018 09:58:45 +0000 (12:58 +0300)
committerSmallJoker <SmallJoker@users.noreply.github.com>
Sat, 3 Mar 2018 09:58:45 +0000 (10:58 +0100)
src/light.h
src/mapblock_mesh.cpp

index f8c4b83c33dd221363a0aa8ea92f20f0fdf7c3a7..203bd851e4f641f4e434d58dcc8601a3e126cf51 100644 (file)
@@ -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
 
 /**
index 48171c84ca99e85d9fbdb6c66aff8af47e65cc17..bdf791c0bf1aae335cff5406c264cda47964ad1f 100644 (file)
@@ -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);
 }