]> git.localhorst.tv Git - blank.git/blob - src/block.cpp
e22d3e63d8ce309f71903a00a69cb985461483dc
[blank.git] / src / block.cpp
1 #include "block.hpp"
2
3
4 namespace blank {
5
6 const NullShape BlockType::DEFAULT_SHAPE;
7
8 void BlockType::FillVBO(
9         const glm::vec3 &pos,
10         std::vector<glm::vec3> &vertices,
11         std::vector<glm::vec3> &colors,
12         std::vector<glm::vec3> &normals
13 ) const {
14         shape->Vertices(vertices, pos);
15         colors.insert(colors.end(), shape->VertexCount(), color);
16         shape->Normals(normals);
17 }
18
19 void BlockType::FillOutlineVBO(
20         std::vector<glm::vec3> &vertices,
21         std::vector<glm::vec3> &colors
22 ) const {
23         shape->Outline(vertices);
24         colors.insert(colors.end(), shape->OutlineCount(), outline_color);
25 }
26
27
28 BlockTypeRegistry::BlockTypeRegistry() {
29         Add(BlockType());
30 }
31
32 int BlockTypeRegistry::Add(const BlockType &t) {
33         int id = types.size();
34         types.push_back(t);
35         types.back().id = id;
36         return id;
37 }
38
39 }