]> git.localhorst.tv Git - blank.git/blob - src/world/BlockType.hpp
renamed OutlineMesh -> PrimitiveMesh
[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/PrimitiveMesh.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         int place_sound;
30         int remove_sound;
31
32         Block::Type id;
33
34         /// light level that blocks of this type emit
35         int luminosity;
36
37         /// whether to draw
38         bool visible;
39         /// if true, stops light from propagating and fixes level to luminosity
40         bool block_light;
41
42         /// whether to check for collisions at all
43         bool collision;
44         /// if the block should be impenetrable
45         bool collide_block;
46
47         // generation properties
48         /// whether to use this block in generation at all
49         bool generate;
50         // min/mid/max points for the respective properties
51         // should all be in the (-1,1) range
52         float min_solidity;
53         float mid_solidity;
54         float max_solidity;
55         float min_humidity;
56         float mid_humidity;
57         float max_humidity;
58         float min_temperature;
59         float mid_temperature;
60         float max_temperature;
61         float min_richness;
62         float mid_richness;
63         float max_richness;
64         /// commonness factor, random chance is multiplied by this
65         float commonness;
66
67         BlockType() noexcept;
68
69         bool FaceFilled(const Block &block, Block::Face face) const noexcept {
70                 return shape && shape->FaceFilled(block.OrientedFace(face));
71         }
72
73         void FillEntityMesh(
74                 EntityMesh::Buffer &m,
75                 const glm::mat4 &transform = glm::mat4(1.0f)
76         ) const noexcept;
77         void FillBlockMesh(
78                 BlockMesh::Buffer &m,
79                 const glm::mat4 &transform = glm::mat4(1.0f),
80                 BlockMesh::Index idx_offset = 0
81         ) const noexcept;
82         void OutlinePrimitiveMesh(PrimitiveMesh::Buffer &) const noexcept;
83
84 };
85
86 }
87
88 #endif