Lighting now uses pathing to determine where it can go, but _distance_ to determin strength. Looks way better.
This commit is contained in:
parent
31620adf7a
commit
f46b5f15ef
8 changed files with 72 additions and 63 deletions
|
@ -10,38 +10,36 @@
|
|||
using namespace lighting;
|
||||
|
||||
TEST_CASE("lighting a map works", "[lighting]") {
|
||||
for(int i = 0; i < 5; i++) {
|
||||
Map map(20+i,23+i);
|
||||
WorldBuilder builder(map);
|
||||
builder.generate();
|
||||
Map map(20,23);
|
||||
WorldBuilder builder(map);
|
||||
builder.generate();
|
||||
|
||||
Point light1 = map.place_entity(0);
|
||||
Point light2 = map.place_entity(1);
|
||||
LightSource source1{7,1};
|
||||
LightSource source2{3,2};
|
||||
Point light1 = map.place_entity(0);
|
||||
Point light2 = map.place_entity(1);
|
||||
LightSource source1{0,2};
|
||||
LightSource source2{1,3};
|
||||
|
||||
LightRender lr(map.width(), map.height());
|
||||
LightRender lr(map.width(), map.height());
|
||||
|
||||
lr.reset_light();
|
||||
lr.reset_light();
|
||||
|
||||
lr.set_light_target(light1);
|
||||
lr.set_light_target(light2);
|
||||
lr.set_light_target(light1);
|
||||
lr.set_light_target(light2);
|
||||
|
||||
lr.path_light(map.walls());
|
||||
lr.path_light(map.walls());
|
||||
|
||||
lr.render_light(source1, light1);
|
||||
lr.render_light(source2, light2);
|
||||
lr.render_light(source1, light1);
|
||||
lr.render_light(source2, light2);
|
||||
|
||||
lr.clear_light_target(light1);
|
||||
lr.clear_light_target(light2);
|
||||
lr.clear_light_target(light1);
|
||||
lr.clear_light_target(light2);
|
||||
|
||||
Matrix &lighting = lr.lighting();
|
||||
Matrix &lighting = lr.lighting();
|
||||
|
||||
//matrix::dump("WALLS=====", map.walls());
|
||||
//matrix::dump("LIGHT PATHS======", lr.$paths.$paths);
|
||||
matrix::dump("WALLS=====", map.walls(), light1.x, light1.y);
|
||||
matrix::dump("LIGHTING======", lighting, light1.x, light1.y);
|
||||
|
||||
// confirm light is set at least at and around the two points
|
||||
REQUIRE(lighting[light1.y][light1.x] == lighting::LEVELS[source1.strength]);
|
||||
REQUIRE(lighting[light2.y][light2.x] == lighting::LEVELS[source2.strength]);
|
||||
}
|
||||
// confirm light is set at least at and around the two points
|
||||
REQUIRE(lighting[light1.y][light1.x] == lighting::LEVELS[source1.strength]);
|
||||
REQUIRE(lighting[light2.y][light2.x] == lighting::LEVELS[source2.strength]);
|
||||
}
|
||||
|
|
|
@ -101,6 +101,27 @@ TEST_CASE("thash matrix iterators", "[matrix]") {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_CASE("thrash box distance iterators", "[matrix:distance]") {
|
||||
size_t width = Random::uniform<size_t>(10, 21);
|
||||
size_t height = Random::uniform<size_t>(10, 25);
|
||||
|
||||
Matrix result(height, matrix::Row(width));
|
||||
matrix::assign(result, 0);
|
||||
|
||||
size_t size = Random::uniform<int>(4, 10);
|
||||
|
||||
Point target{width/2, height/2};
|
||||
matrix::in_box box{result, target.x, target.y, size};
|
||||
while(box.next()) {
|
||||
result[box.y][box.x] = box.distance();
|
||||
}
|
||||
|
||||
matrix::dump(format("MAP {}x{} @ {},{}; BOX {}x{}; size: {}",
|
||||
matrix::width(result), matrix::height(result),
|
||||
target.x, target.y, box.right - box.left, box.bottom - box.top, size),
|
||||
result, target.x, target.y);
|
||||
}
|
||||
|
||||
TEST_CASE("thrash box iterators", "[matrix]") {
|
||||
for(int count = 0; count < 20; count++) {
|
||||
size_t width = Random::uniform<size_t>(1, 25);
|
||||
|
@ -250,7 +271,7 @@ TEST_CASE("prototype circle algorithm", "[matrix:circle]") {
|
|||
}
|
||||
}
|
||||
|
||||
matrix::dump(format("RESULT AFTER CIRCLE radius {}", radius), result, start.x, start.y);
|
||||
// matrix::dump(format("RESULT AFTER CIRCLE radius {}", radius), result, start.x, start.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue