Lighting is now in its own class using the new Pathing class. This should allow me to make it more consistent and possibly make Pathing more efficient.

This commit is contained in:
Zed A. Shaw 2024-12-01 17:54:43 -05:00
parent e05335b153
commit 3f7a9cc124
18 changed files with 209 additions and 257 deletions

View file

@ -3,7 +3,8 @@
#include "dbc.hpp"
#include "point.hpp"
#include <algorithm>
#include "map.hpp"
#include "matrix.hpp"
#include "pathing.hpp"
namespace lighting {
@ -28,4 +29,30 @@ namespace lighting {
60,
MIN,
};
class LightRender {
public:
int $limit;
size_t $width;
size_t $height;
Matrix $lightmap;
Pathing $light;
LightRender(size_t width, size_t height, int limit) :
$limit(limit),
$width(width),
$height(height),
$lightmap(height, MatrixRow(width, 0)),
$light(width, height, limit)
{}
void reset_light();
void set_light_target(const Point &at, int value=0);
void clear_light_target(const Point &at);
void path_light(Matrix &walls);
void light_box(LightSource source, Point from, Point &min_out, Point &max_out);
int light_level(int level, size_t x, size_t y);
void render_light(LightSource source, Point at);
Matrix &lighting() { return $lightmap; }
};
}