]> git.localhorst.tv Git - blank.git/blob - src/block.cpp
50c4a4ffd9040c136f6bfcdebff4704dc8fcdb33
[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::FillModel(
9         Model &model,
10         const glm::vec3 &pos_offset,
11         Model::Index idx_offset
12 ) const {
13         shape->Vertices(model.vertices, model.normals, model.indices, pos_offset, idx_offset);
14         model.colors.insert(model.colors.end(), shape->VertexCount(), color);
15 }
16
17 void BlockType::FillOutlineModel(
18         OutlineModel &model,
19         const glm::vec3 &pos_offset,
20         OutlineModel::Index idx_offset
21 ) const {
22         shape->Outline(model.vertices, model.indices, pos_offset, idx_offset);
23         model.colors.insert(model.colors.end(), shape->OutlineCount(), outline_color);
24 }
25
26
27 BlockTypeRegistry::BlockTypeRegistry() {
28         Add(BlockType());
29 }
30
31 int BlockTypeRegistry::Add(const BlockType &t) {
32         int id = types.size();
33         types.push_back(t);
34         types.back().id = id;
35         return id;
36 }
37
38 }