|
|
|
|
@ -62,8 +62,10 @@ const DisplacementOf<int8_t> VisionCrawlTable[23][15] = {
|
|
|
|
|
// clang-format on
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
/** 16 falloff tables for the light cone */ |
|
|
|
|
uint8_t LightFalloffs[16][128]; |
|
|
|
|
/** @brief Number of supported light radiuses (first radius starts with 0) */ |
|
|
|
|
constexpr size_t NumLightRadiuses = 16; |
|
|
|
|
/** Falloff tables for the light cone */ |
|
|
|
|
uint8_t LightFalloffs[NumLightRadiuses][128]; |
|
|
|
|
bool dovision; |
|
|
|
|
/** interpolations of a 32x32 (16x16 mirrored) light circle moving between tiles in steps of 1/8 of a tile */ |
|
|
|
|
uint8_t LightConeInterpolations[8][8][16][16]; |
|
|
|
|
@ -218,6 +220,9 @@ bool DoCrawl(unsigned minRadius, unsigned maxRadius, tl::function_ref<bool(Displ
|
|
|
|
|
|
|
|
|
|
void DoLighting(Point position, int nRadius, int lnum) |
|
|
|
|
{ |
|
|
|
|
assert(nRadius >= 0 && nRadius <= NumLightRadiuses); |
|
|
|
|
assert(InDungeonBounds(position)); |
|
|
|
|
|
|
|
|
|
int xoff = 0; |
|
|
|
|
int yoff = 0; |
|
|
|
|
int lightX = 0; |
|
|
|
|
@ -259,12 +264,10 @@ void DoLighting(Point position, int nRadius, int lnum)
|
|
|
|
|
maxY = MAXDUNY - position.y; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (InDungeonBounds(position)) { |
|
|
|
|
if (IsNoneOf(leveltype, DTYPE_NEST, DTYPE_CRYPT)) { |
|
|
|
|
SetLight(position, 0); |
|
|
|
|
} else if (GetLight(position) > LightFalloffs[nRadius][0]) { |
|
|
|
|
SetLight(position, LightFalloffs[nRadius][0]); |
|
|
|
|
} |
|
|
|
|
if (IsNoneOf(leveltype, DTYPE_NEST, DTYPE_CRYPT)) { |
|
|
|
|
SetLight(position, 0); |
|
|
|
|
} else if (GetLight(position) > LightFalloffs[nRadius][0]) { |
|
|
|
|
SetLight(position, LightFalloffs[nRadius][0]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 4; i++) { |
|
|
|
|
@ -394,21 +397,21 @@ void MakeLightTable()
|
|
|
|
|
|
|
|
|
|
// Generate light falloffs ranges
|
|
|
|
|
if (IsAnyOf(leveltype, DTYPE_NEST, DTYPE_CRYPT)) { |
|
|
|
|
for (int j = 0; j < 16; j++) { |
|
|
|
|
for (int j = 0; j < NumLightRadiuses; j++) { |
|
|
|
|
double fa = (sqrt((double)(16 - j))) / 128; |
|
|
|
|
fa *= fa; |
|
|
|
|
for (int i = 0; i < 128; i++) { |
|
|
|
|
uint8_t color = 15 - static_cast<uint8_t>(fa * (double)((128 - i) * (128 - i))); |
|
|
|
|
if (color > 15) |
|
|
|
|
color = 0; |
|
|
|
|
color -= static_cast<uint8_t>((15 - j) / 2); |
|
|
|
|
color -= static_cast<uint8_t>((NumLightRadiuses - j - 1) / 2); |
|
|
|
|
if (color > 15) |
|
|
|
|
color = 0; |
|
|
|
|
LightFalloffs[15 - j][i] = color; |
|
|
|
|
LightFalloffs[NumLightRadiuses - j - 1][i] = color; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
for (int j = 0; j < 16; j++) { |
|
|
|
|
for (int j = 0; j < NumLightRadiuses; j++) { |
|
|
|
|
for (int i = 0; i < 128; i++) { |
|
|
|
|
if (i > (j + 1) * 8) { |
|
|
|
|
LightFalloffs[j][i] = 15; |
|
|
|
|
|