]> git.localhorst.tv Git - blank.git/blob - src/world/BlockType.hpp
use (and fix) new shape implementation
[blank.git] / src / world / BlockType.hpp
1 #ifndef BLANK_WORLD_BLOCKTYPE_HPP_
2 #define BLANK_WORLD_BLOCKTYPE_HPP_
3
4 #include "Block.hpp"
5 #include "../graphics/BlockMesh.hpp"
6 #include "../graphics/EntityMesh.hpp"
7 #include "../graphics/OutlineMesh.hpp"
8 #include "../model/Shape.hpp"
9
10 #include <glm/glm.hpp>
11 #include <vector>
12
13
14 namespace blank {
15
16 /// single 1x1x1 cube
17 /// attributes of a type of block
18 struct BlockType {
19
20         const Shape *shape;
21         std::vector<float> textures;
22         glm::vec3 hsl_mod;
23         glm::vec3 rgb_mod;
24         glm::vec3 outline_color;
25
26         /// a string to display to the user
27         std::string label;
28
29         Block::Type id;
30
31         /// light level that blocks of this type emit
32         int luminosity;
33
34         /// whether to draw
35         bool visible;
36         /// if true, stops light from propagating and fixes level to luminosity
37         bool block_light;
38
39         /// whether to check for collisions at all
40         bool collision;
41         /// if the block should be impenetrable
42         bool collide_block;
43
44         // generation properties
45         /// whether to use this block in generation at all
46         bool generate;
47         // min/mid/max points for the respective properties
48         // should all be in the (-1,1) range
49         float min_solidity;
50         float mid_solidity;
51         float max_solidity;
52         float min_humidity;
53         float mid_humidity;
54         float max_humidity;
55         float min_temperature;
56         float mid_temperature;
57         float max_temperature;
58         float min_richness;
59         float mid_richness;
60         float max_richness;
61         /// commonness factor, random chance is multiplied by this
62         float commonness;
63
64         BlockType() noexcept;
65
66         bool FaceFilled(const Block &block, Block::Face face) const noexcept {
67                 return shape && shape->FaceFilled(block.OrientedFace(face));
68         }
69
70         void FillEntityMesh(
71                 EntityMesh::Buffer &m,
72                 const glm::mat4 &transform = glm::mat4(1.0f)
73         ) const noexcept;
74         void FillBlockMesh(
75                 BlockMesh::Buffer &m,
76                 const glm::mat4 &transform = glm::mat4(1.0f),
77                 BlockMesh::Index idx_offset = 0
78         ) const noexcept;
79         void FillOutlineMesh(OutlineMesh::Buffer &m) const noexcept;
80
81 };
82
83 }
84
85 #endif