]> git.localhorst.tv Git - blank.git/blob - src/world.hpp
split entity from controller
[blank.git] / src / world.hpp
1 #ifndef BLANK_WORLD_HPP_
2 #define BLANK_WORLD_HPP_
3
4 #include "block.hpp"
5 #include "chunk.hpp"
6 #include "entity.hpp"
7 #include "noise.hpp"
8 #include "shader.hpp"
9 #include "shape.hpp"
10
11 #include <list>
12 #include <glm/glm.hpp>
13
14
15 namespace blank {
16
17 class World {
18
19 public:
20         World();
21
22         void Generate(const glm::tvec3<int> &from, const glm::tvec3<int> &to);
23
24         bool Intersection(
25                 const Ray &,
26                 const glm::mat4 &M,
27                 Chunk **chunk = nullptr,
28                 int *blkid = nullptr,
29                 float *dist = nullptr,
30                 glm::vec3 *normal = nullptr);
31
32         BlockTypeRegistry &BlockTypes() { return blockType; }
33         std::list<Chunk> &LoadedChunks() { return loaded; }
34
35         Entity &Player() { return player; }
36
37         Chunk &Next(const Chunk &, const glm::vec3 &dir);
38
39         void Update(int dt);
40
41         void Render(DirectionalLighting &);
42
43 private:
44         void Generate(Chunk &);
45
46 private:
47         BlockTypeRegistry blockType;
48         CuboidShape blockShape;
49         StairShape stairShape;
50         CuboidShape slabShape;
51
52         SimplexNoise blockNoise;
53         SimplexNoise colorNoise;
54
55         Entity player;
56
57         std::list<Chunk> loaded;
58         std::list<Chunk> to_generate;
59
60 };
61
62 }
63
64 #endif