|
|
@ -1,13 +1,11 @@ |
|
|
|
#include "lights.hpp" |
|
|
|
#include "lights.hpp" |
|
|
|
|
|
|
|
#include "constants.hpp" |
|
|
|
#include <vector> |
|
|
|
#include <vector> |
|
|
|
|
|
|
|
|
|
|
|
const int WALL_LIGHT_LEVEL = 3; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using std::vector; |
|
|
|
using std::vector; |
|
|
|
|
|
|
|
|
|
|
|
namespace lighting { |
|
|
|
namespace lighting { |
|
|
|
void LightRender::render_light(LightSource source, Point at) { |
|
|
|
void LightRender::render_light(LightSource source, Point at) { |
|
|
|
const int UNPATH = $limit; |
|
|
|
|
|
|
|
Point min, max; |
|
|
|
Point min, max; |
|
|
|
light_box(source, at, min, max); |
|
|
|
light_box(source, at, min, max); |
|
|
|
clear_light_target(at); |
|
|
|
clear_light_target(at); |
|
|
@ -18,7 +16,7 @@ namespace lighting { |
|
|
|
auto &path_row = $paths.$paths[y]; |
|
|
|
auto &path_row = $paths.$paths[y]; |
|
|
|
|
|
|
|
|
|
|
|
for(size_t x = min.x; x <= max.x; ++x) { |
|
|
|
for(size_t x = min.x; x <= max.x; ++x) { |
|
|
|
if(path_row[x] != UNPATH) { |
|
|
|
if(path_row[x] != WALL_PATH_LIMIT) { |
|
|
|
light_row[x] = light_level(source.strength, x, y); |
|
|
|
light_row[x] = light_level(source.strength, x, y); |
|
|
|
has_light.push_back({x,y}); |
|
|
|
has_light.push_back({x,y}); |
|
|
|
} |
|
|
|
} |
|
|
@ -32,7 +30,7 @@ namespace lighting { |
|
|
|
auto &light_row = $lightmap[point.y+j]; |
|
|
|
auto &light_row = $lightmap[point.y+j]; |
|
|
|
|
|
|
|
|
|
|
|
for(int i = -1; point.x+i >= 0 && i <= 1 && point.x+i < $width; i++) { |
|
|
|
for(int i = -1; point.x+i >= 0 && i <= 1 && point.x+i < $width; i++) { |
|
|
|
if(path_row[point.x+i] == UNPATH) { |
|
|
|
if(path_row[point.x+i] == WALL_PATH_LIMIT) { |
|
|
|
light_row[point.x+i] = light_level(wall_light, point.x, point.y); |
|
|
|
light_row[point.x+i] = light_level(wall_light, point.x, point.y); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|