mirror of
https://github.com/diasurgical/devilution.git
synced 2025-07-23 04:23:01 +02:00
lighting: add BUGFIX for MakeLightTable
The i/j/k/l variables obfuscate the fact that the distance formula used for generating data in lightblock is using the x offset with the y component of the tile coordinate and vice-versa. Mixing x and y this way causes light to move horizontally within a tile when the light source is moving vertically and vice-versa.
This commit is contained in:
@@ -1003,6 +1003,9 @@ void MakeLightTable()
|
||||
fs = (BYTE)sqrt((8 * l - j) * (8 * l - j) + (8 * k - i) * (8 * k - i));
|
||||
fs += fs < 0 ? -0.5 : 0.5;
|
||||
|
||||
// BUGFIX: This error causes a "jittery" effect when a light source moves.
|
||||
// Swap the addition and multiplication operators to fix the lookup table.
|
||||
// lightblock[j + 8 * i][k][l] = fs;
|
||||
lightblock[j * 8 + i][k][l] = fs;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user