Browse Source

Make IsFullyDark/IsFullyLit respect hell and hellfire levels

pull/7168/head
obligaron 2 years ago committed by Anders Jenbo
parent
commit
4b7424949f
  1. 4
      Source/engine/render/dun_render.cpp
  2. 9
      Source/lighting.cpp
  3. 4
      Source/lighting.h

4
Source/engine/render/dun_render.cpp

@ -284,12 +284,12 @@ DVL_ALWAYS_INLINE Clip CalculateClip(int_fast16_t x, int_fast16_t y, int_fast16_
DVL_ALWAYS_INLINE bool IsFullyDark(const uint8_t *DVL_RESTRICT tbl)
{
return tbl == LightTables[LightsMax].data();
return tbl == FullyDarkLightTable;
}
DVL_ALWAYS_INLINE bool IsFullyLit(const uint8_t *DVL_RESTRICT tbl)
{
return tbl == LightTables[0].data();
return tbl == FullyLitLightTable;
}
template <LightType Light, bool Transparent>

9
Source/lighting.cpp

@ -24,6 +24,8 @@ Light Lights[MAXLIGHTS];
std::array<uint8_t, MAXLIGHTS> ActiveLights;
int ActiveLightCount;
std::array<std::array<uint8_t, 256>, NumLightingLevels> LightTables;
uint8_t *FullyLitLightTable = nullptr;
uint8_t *FullyDarkLightTable = nullptr;
std::array<uint8_t, 256> InfravisionTable;
std::array<uint8_t, 256> StoneTable;
std::array<uint8_t, 256> PauseTable;
@ -345,6 +347,8 @@ void MakeLightTable()
}
LightTables[15] = {}; // Make last shade pitch black
FullyLitLightTable = LightTables[0].data();
FullyDarkLightTable = LightTables[LightsMax].data();
if (leveltype == DTYPE_HELL) {
// Blood wall lighting
@ -361,14 +365,19 @@ void MakeLightTable()
lightTable[idx] = color;
}
}
FullyLitLightTable = nullptr; // A color map is used for the ceiling animation, so even fully lit tiles have a color map
} else if (IsAnyOf(leveltype, DTYPE_NEST, DTYPE_CRYPT)) {
// Make the lava fully bright
for (auto &lightTable : LightTables)
std::iota(lightTable.begin(), lightTable.begin() + 16, uint8_t { 0 });
LightTables[15][0] = 0;
std::fill_n(LightTables[15].begin() + 1, 15, 1);
FullyDarkLightTable = nullptr; // Tiles in Hellfire levels are never completely black
}
assert((FullyLitLightTable != nullptr) == (LightTables[0][0] == 0 && std::adjacent_find(LightTables[0].begin(), LightTables[0].end() - 1, [](auto x, auto y) { return (x + 1) != y; }) == LightTables[0].end() - 1));
assert((FullyDarkLightTable != nullptr) == (std::all_of(LightTables[LightsMax].begin(), LightTables[LightsMax].end(), [](auto x) { return x == 0; })));
LoadFileInMem("plrgfx\\infra.trn", InfravisionTable);
LoadFileInMem("plrgfx\\stone.trn", StoneTable);
LoadFileInMem("gendata\\pause.trn", PauseTable);

4
Source/lighting.h

@ -49,6 +49,10 @@ extern std::array<uint8_t, MAXLIGHTS> ActiveLights;
extern int ActiveLightCount;
constexpr char LightsMax = 15;
extern std::array<std::array<uint8_t, 256>, NumLightingLevels> LightTables;
/** @brief Contains a pointer to a light table that is fully lit (no color mapping is required). Can be null in hell. */
extern uint8_t *FullyLitLightTable;
/** @brief Contains a pointer to a light table that is fully dark (every color result to 0/black). Can be null in hellfire levels. */
extern uint8_t *FullyDarkLightTable;
extern std::array<uint8_t, 256> InfravisionTable;
extern std::array<uint8_t, 256> StoneTable;
extern std::array<uint8_t, 256> PauseTable;

Loading…
Cancel
Save