Circle iterator now compensates for the matrix size and won't overflow.
This commit is contained in:
parent
35f2defc11
commit
857cd2f910
5 changed files with 25 additions and 23 deletions
10
lights.cpp
10
lights.cpp
|
@ -7,14 +7,10 @@ using std::vector;
|
|||
namespace lighting {
|
||||
|
||||
void LightRender::render_circle_light(LightSource source, Point at, PointList &has_light) {
|
||||
for(matrix::circle it{at, source.distance + 1}; it.next();) {
|
||||
for(matrix::circle it{$lightmap, at, source.distance + 1}; it.next();) {
|
||||
for(int x = it.left; x < it.right; x++) {
|
||||
if(matrix::inbounds($paths.$paths, x, it.y) &&
|
||||
$paths.$paths[it.y][x] != WALL_PATH_LIMIT)
|
||||
{
|
||||
$lightmap[it.y][x] = light_level(source.strength, x, it.y);
|
||||
has_light.push_back({(size_t)x, (size_t)it.y});
|
||||
}
|
||||
$lightmap[it.y][x] = light_level(source.strength, x, it.y);
|
||||
has_light.push_back({(size_t)x, (size_t)it.y});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue