X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fchunk.hpp;h=0b1e5bdec20f79f65971e23234a5d77e04cd2dfd;hb=38abfe4f5342f20b56052ac3090694eabf028d16;hp=d8408ec9062e34bbb4f5344c4cb9df79eef0dd5b;hpb=32a2a1231de8438f8408007c41247361b1c52417;p=blank.git diff --git a/src/chunk.hpp b/src/chunk.hpp index d8408ec..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,19 +148,41 @@ 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 &);