summaryrefslogtreecommitdiff
path: root/src/light.cpp
diff options
context:
space:
mode:
authorVitaliy <silverunicorn2011@yandex.ru>2017-12-12 21:29:55 +0300
committerSmallJoker <SmallJoker@users.noreply.github.com>2017-12-12 19:29:55 +0100
commit2d9f0d344e45282638f9c1c1b57019c5e7f3999c (patch)
treef39357d702e0317a18b240e3eb059b259fc5692b /src/light.cpp
parentb19241b9bc43e2d9721927ab32e5e56345721652 (diff)
downloadminetest-2d9f0d344e45282638f9c1c1b57019c5e7f3999c.tar.gz
minetest-2d9f0d344e45282638f9c1c1b57019c5e7f3999c.tar.bz2
minetest-2d9f0d344e45282638f9c1c1b57019c5e7f3999c.zip
Update light decoding table size (#6696)
Fix old undiminish_light bug
Diffstat (limited to 'src/light.cpp')
-rw-r--r--src/light.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/light.cpp b/src/light.cpp
index 4a20c58ab..c63ffc3bd 100644
--- a/src/light.cpp
+++ b/src/light.cpp
@@ -24,9 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#ifndef SERVER
-// Length of LIGHT_MAX + 1 means LIGHT_MAX is the last value.
-// LIGHT_SUN is read as LIGHT_MAX from here.
-u8 light_LUT[LIGHT_MAX + 1];
+static u8 light_LUT[LIGHT_SUN + 1];
// The const ref to light_LUT is what is actually used in the code
const u8 *light_decode_table = light_LUT;
@@ -48,9 +46,9 @@ void set_light_table(float gamma)
// Gamma correction
gamma = rangelim(gamma, 0.5f, 3.0f);
- for (size_t i = 0; i < LIGHT_MAX; i++) {
+ for (size_t i = 0; i < LIGHT_SUN; i++) {
float x = i;
- x /= LIGHT_MAX;
+ x /= LIGHT_SUN;
float brightness = a * x * x * x + b * x * x + c * x;
float boost = d * std::exp(-((x - e) * (x - e)) / (2.0f * f * f));
brightness = powf(brightness + boost, 1.0f / gamma);
@@ -58,6 +56,6 @@ void set_light_table(float gamma)
if (i > 1 && light_LUT[i] <= light_LUT[i - 1])
light_LUT[i] = light_LUT[i - 1] + 1;
}
- light_LUT[LIGHT_MAX] = 255;
+ light_LUT[LIGHT_SUN] = 255;
}
#endif