X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fchunk.hpp;h=0b1e5bdec20f79f65971e23234a5d77e04cd2dfd;hb=e74f1ad236429f05db90c0ace825277e2a3fbc05;hp=c7bcd2ffe7313e5c2c1542f2b13b4962c5f8fd10;hpb=774253e509ce13881229efda8849bf6f3c47b665;p=blank.git diff --git a/src/chunk.hpp b/src/chunk.hpp index c7bcd2f..0b1e5bd 100644 --- a/src/chunk.hpp +++ b/src/chunk.hpp @@ -116,6 +116,8 @@ public: int GetLight(const Pos &pos) const { return GetLight(ToIndex(pos)); } int GetLight(const Block::Pos &pos) const { return GetLight(ToIndex(pos)); } + float GetVertexLight(int index, const BlockModel::Position &, const BlockModel::Normal &) const; + bool Intersection( const Ray &ray, const glm::mat4 &M, @@ -146,21 +148,44 @@ private: Chunk *neighbor[Block::FACE_COUNT]; std::vector blocks; std::vector light; - Model model; + BlockModel model; Pos position; bool dirty; }; +struct BlockLookup { + + Chunk *chunk; + Chunk::Pos pos; + const Block *result; + + // resolve chunk/position/block from oob coordinates + // result will be nullptr if unsuccessful + BlockLookup(Chunk *c, const Chunk::Pos &p); + + // resolve chunk/position/block from ib coordinates and direction + // result will be nullptr if unsuccessful + BlockLookup(Chunk *c, const Chunk::Pos &p, Block::Face dir); + +}; + + class Generator; class ChunkLoader { public: - ChunkLoader(const BlockTypeRegistry &, const Generator &); + struct Config { + int load_dist = 6; + int unload_dist = 8; + }; + + ChunkLoader(const Config &, const BlockTypeRegistry &, const Generator &); void Generate(const Chunk::Pos &from, const Chunk::Pos &to); + void GenerateSurrounding(const Chunk::Pos &); std::list &Loaded() { return loaded; }