Browse Source

Fix Hell modification of the light table

There was a precission issue that caused some jitter in the light table.
This is solved and made made more redable by using a shift instead of
tricky use of remander from a devision.
pull/6014/head
Anders Jenbo 3 years ago
parent
commit
53d4e72e19
  1. 48
      Source/lighting.cpp

48
Source/lighting.cpp

@ -400,45 +400,17 @@ void MakeLightTable()
} }
if (leveltype == DTYPE_HELL) { if (leveltype == DTYPE_HELL) {
uint8_t blood[16]; // Blood wall lighting
tbl = LightTables[0].data(); const int shades = LightTables.size() - 1;
for (int i = 0; i < lights; i++) { for (int i = 0; i < shades; i++) {
int l1 = lights - i; auto &lightTable = LightTables[i];
int l2 = l1; constexpr int range = 16;
int div = lights / l1; for (int j = 0; j < range; j++) {
int rem = lights % l1; uint8_t color = ((range - 1) << 4) / shades * (shades - i) / range * (j + 1);
int cnt = 0; color = 1 + (color >> 4);
blood[0] = 0; lightTable[j + 1] = color;
uint8_t col = 1; lightTable[31 - j] = color;
for (int j = 1; j < 16; j++) {
blood[j] = col;
l2 += rem;
if (l2 > l1 && j < 15) {
j++;
blood[j] = col;
l2 -= l1;
}
cnt++;
if (cnt == div) {
col++;
cnt = 0;
}
}
*tbl++ = 0;
for (int j = 1; j <= 15; j++) {
*tbl++ = blood[j];
} }
for (int j = 15; j > 0; j--) {
*tbl++ = blood[j];
}
*tbl++ = 1;
tbl += 224;
}
*tbl++ = 0;
for (int j = 0; j < 31; j++) {
*tbl++ = 1;
}
tbl += 224;
} }
} else if (IsAnyOf(leveltype, DTYPE_NEST, DTYPE_CRYPT)) { } else if (IsAnyOf(leveltype, DTYPE_NEST, DTYPE_CRYPT)) {
// Make the lava fully bright // Make the lava fully bright

Loading…
Cancel
Save