1 #ifndef BLANK_WORLD_WORLD_HPP_
2 #define BLANK_WORLD_WORLD_HPP_
4 #include "ChunkLoader.hpp"
6 #include "Generator.hpp"
10 #include <glm/glm.hpp>
15 class BlockTypeRegistry;
16 class EntityCollision;
24 // initial player position
25 glm::vec3 spawn = { 0.0f, 0.0f, 0.0f };
26 // direction facing towards(!) the light
27 glm::vec3 light_direction = { -1.0f, -3.0f, -2.0f };
28 // fade out reaches 1/e (0.3679) at 1/fog_density,
29 // gets less than 0.01 at e/(2 * fog_density)
30 // I chose 0.011 because it yields 91 and 124 for those, so
31 // slightly less than 6 and 8 chunks
32 float fog_density = 0.011f;
34 Generator::Config gen = Generator::Config();
35 ChunkLoader::Config load = ChunkLoader::Config();
38 World(const BlockTypeRegistry &, const Config &, const WorldSave &);
40 /// check if this ray hits a block
41 /// depth in the collision is the distance between the ray's
42 /// origin and the intersection point
43 /// M is the global transform for given reference chunk
47 const Chunk::Pos &reference,
50 /// check if this ray hits an entity
51 /// intersections with the reference are not tested
52 /// M is the global transform for the chunk of given reference entity
56 const Entity &reference,
59 /// check if given entity intersects with the world
60 bool Intersection(const Entity &e, std::vector<WorldCollision> &);
61 void Resolve(Entity &e, std::vector<WorldCollision> &);
63 const BlockTypeRegistry &BlockTypes() noexcept { return block_type; }
64 ChunkLoader &Loader() noexcept { return chunks; }
66 /// add player with given name
67 /// returns nullptr if the name is already taken
68 Entity *AddPlayer(const std::string &name);
69 Entity &AddEntity() { entities.emplace_back(); return entities.back(); }
71 const std::vector<Entity *> &Players() const noexcept { return players; }
72 const std::list<Entity> &Entities() const noexcept { return entities; }
76 void Render(Viewport &);
81 const BlockTypeRegistry &block_type;
86 std::vector<Entity *> players;
87 std::list<Entity> entities;
89 glm::vec3 light_direction;