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

30
map.hpp
View file

@ -8,6 +8,8 @@
#include "point.hpp"
#include "tser.hpp"
#include "lights.hpp"
#include "pathing.hpp"
#include "matrix.hpp"
#define INV_WALL 0
#define INV_SPACE 1
@ -27,9 +29,6 @@ struct Room {
DEFINE_SERIALIZABLE(Room, x, y, width, height);
};
typedef std::vector<int> MatrixRow;
typedef std::vector<MatrixRow> Matrix;
void dump_map(const std::string &msg, Matrix &map);
class Map {
@ -37,30 +36,22 @@ public:
int $limit;
size_t $width;
size_t $height;
Matrix $input_map;
Matrix $walls;
Matrix $paths;
Matrix $lightmap;
Matrix $light_paths;
Matrix $light_input;
Pathing $paths;
std::vector<Room> $rooms;
Map(Matrix input_map, Matrix walls_map, int limit);
// make random
Map(size_t width, size_t height);
// disable copying
Map(Map &map) = delete;
Matrix& paths() { return $paths; }
Matrix& lighting() { return $lightmap; }
Matrix& input_map() { return $input_map; }
Matrix& paths() { return $paths.paths(); }
Matrix& input_map() { return $paths.input(); }
Matrix& walls() { return $walls; }
int limit() { return $limit; }
size_t width() { return $width; }
size_t height() { return $height; }
int distance(Point to) { return $paths[to.y][to.x]; }
int distance(Point to) { return $paths.distance(to); }
Room &room(size_t at) { return $rooms[at]; }
size_t room_count() { return $rooms.size(); }
@ -78,7 +69,6 @@ public:
bool inmap(size_t x, size_t y);
bool iswall(size_t x, size_t y);
void pathing_for(Matrix &input_map, Matrix &path_for);
void make_paths();
void set_target(const Point &at, int value=0);
void clear_target(const Point &at);
@ -87,14 +77,6 @@ public:
Point map_to_camera(const Point &loc, const Point &cam_orig);
Point center_camera(const Point &around, size_t view_x, size_t view_y);
void reset_light();
void set_light_target(const Point &at, int value=0);
void clear_light_target(const Point &at);
void path_light();
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);
void dump();
bool INVARIANT();
};