X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld.hpp;h=1d43fbe7ffce45e2929ea659ea48293be33daa33;hb=15ff5ed48855c6bd09bc8f5152f46065484c1e94;hp=4823c47b0c8c0ec804f62f10c5d83f4e5c2dbd04;hpb=8acc3f990f1a5ee00471f72c150b407164149f2d;p=blank.git diff --git a/src/world.hpp b/src/world.hpp index 4823c47..1d43fbe 100644 --- a/src/world.hpp +++ b/src/world.hpp @@ -17,9 +17,22 @@ namespace blank { class World { public: - World(); - - void Generate(const Chunk::Pos &from, const Chunk::Pos &to); + struct Config { + // initial player position + glm::vec3 spawn = { 4.0f, 4.0f, 4.0f }; + // direction facing towards(!) the light + glm::vec3 light_direction = { -1.0f, -3.0f, -2.0f }; + // fade out reaches 1/e (0.3679) at 1/fog_density, + // gets less than 0.01 at e/(2 * fog_density) + // I chose 0.011 because it yields 91 and 124 for those, so + // slightly less than 6 and 8 chunks + float fog_density = 0.011f; + + Generator::Config gen = Generator::Config(); + ChunkLoader::Config load = ChunkLoader::Config(); + }; + + explicit World(const Config &); bool Intersection( const Ray &, @@ -30,19 +43,16 @@ public: glm::vec3 *normal = nullptr); BlockTypeRegistry &BlockTypes() { return blockType; } - std::list &LoadedChunks() { return loaded; } - Entity &Player() { return player; } + Entity &Player() { return *player; } + Entity &AddEntity() { entities.emplace_back(); return entities.back(); } - Chunk *ChunkLoaded(const Chunk::Pos &); - Chunk *ChunkQueued(const Chunk::Pos &); - Chunk *ChunkAvailable(const Chunk::Pos &); - Chunk &Next(const Chunk &, const glm::tvec3 &dir); + Chunk &PlayerChunk(); + Chunk &Next(const Chunk &to, const glm::tvec3 &dir); void Update(int dt); - void CheckChunkGeneration(); - void Render(DirectionalLighting &); + void Render(BlockLighting &, DirectionalLighting &); private: BlockTypeRegistry blockType; @@ -51,13 +61,13 @@ private: CuboidShape slabShape; Generator generate; + ChunkLoader chunks; - Entity player; - Chunk::Pos player_chunk; + Entity *player; + std::list entities; - std::list loaded; - std::list to_generate; - std::list to_free; + glm::vec3 light_direction; + float fog_density; };