Iterators are now working far more reliably and have more extensive tests that randomize inputs and fuzz them to check they keep working.

This commit is contained in:
Zed A. Shaw 2024-12-15 19:38:16 -05:00
parent 8e470df554
commit 70cd963e5c
11 changed files with 318 additions and 84 deletions

View file

@ -7,19 +7,24 @@ using std::vector;
namespace lighting {
void LightRender::render_light(LightSource source, Point at) {
Point min, max;
light_box(source, at, min, max);
clear_light_target(at);
vector<Point> has_light;
for(size_t y = min.y; y <= max.y; ++y) {
auto &light_row = $lightmap[y];
auto &path_row = $paths.$paths[y];
matrix::in_box it{$lightmap, at.x, at.y, (size_t)source.distance};
light_box(source, at, min, max);
for(size_t x = min.x; x <= max.x; ++x) {
if(path_row[x] != WALL_PATH_LIMIT) {
light_row[x] = light_level(source.strength, x, y);
has_light.push_back({x,y});
}
dbc::check(it.x+1 == min.x, "box min x different");
dbc::check(it.y == min.y, "box min y different");
dbc::check(it.right == max.x + 1, "box max.x/right different");
dbc::check(it.bottom == max.y + 1, "box max.y/bottom different");
while(it.next()) {
auto &light_row = $lightmap[it.y];
auto &path_row = $paths.$paths[it.y];
if(path_row[it.x] != WALL_PATH_LIMIT) {
light_row[it.x] = light_level(source.strength, it.x, it.y);
has_light.push_back({it.x, it.y});
}
}