VOX
A little voxel engine
Loading...
Searching...
No Matches
Structures.hpp
Go to the documentation of this file.
1#pragma once
2
3
4#include "define.hpp"
5
6#include "Block.hpp"
7
9
10typedef std::vector<std::vector<std::vector<BlockInfo::Type>>> StructureBlocks;
11
13{
14public:
15 enum class Type : uint16_t
16 {
17 Tree,
18 None
19 } const id = Type::None;
20
21 StructureInfo() = delete;
22 StructureInfo(const Type & type, const glm::ivec3 & size, const std::vector<std::vector<std::vector<BlockInfo::Type>>> & blocks) :
23 id(type),
24 size(size),
25 blocks(blocks)
26 {
27
28 }
29
30
31 const glm::ivec3 size = { 0, 0, 0 };
32 BlockInfo::Type getBlock(const glm::ivec3 & pos) const
33 {
34 return blocks[pos.y][pos.z][pos.x];
35 }
36private:
37 const StructureBlocks blocks;
38};
39
41{
42public:
43
44 static const StructuresInfo & getInstance()
45 {
46 static StructuresInfo instance;
47 return instance;
48 }
49
50 const StructureInfo & get(const StructureInfo::Type id) const
51 {
52 return m_infos[static_cast<size_t>(id)];
53 }
54
55private:
56
57 std::vector<StructureInfo> m_infos;
58
60};
61
const StructuresInfo & g_structures_info
Definition: Structures.cpp:3
std::vector< std::vector< std::vector< BlockInfo::Type > > > StructureBlocks
Definition: Structures.hpp:10
Type
Definition: Block.hpp:33
Definition: Structures.hpp:13
BlockInfo::Type getBlock(const glm::ivec3 &pos) const
Definition: Structures.hpp:32
Type
Definition: Structures.hpp:16
const glm::ivec3 size
Definition: Structures.hpp:31
StructureInfo()=delete
StructureInfo(const Type &type, const glm::ivec3 &size, const std::vector< std::vector< std::vector< BlockInfo::Type > > > &blocks)
Definition: Structures.hpp:22
enum StructureInfo::Type id
Definition: Structures.hpp:41
static const StructuresInfo & getInstance()
Definition: Structures.hpp:44
const StructureInfo & get(const StructureInfo::Type id) const
Definition: Structures.hpp:50