Rehti MMORPG  1.0.0
Rehti MMORPG is a free and open source MMORPG game.
AABB.hpp
Go to the documentation of this file.
1 #include <glm/vec3.hpp>
2 #include <memory>
3 #include <string>
4 #include <vector>
5 
13 struct AABB
14 {
15  AABB(glm::vec3 min = glm::vec3(0.f), glm::vec3 max = glm::vec3(0.f), std::unique_ptr<AABB> pLeft = nullptr, std::unique_ptr<AABB> pRight = nullptr);
16  AABB(AABB& other);
17  AABB& operator=(AABB& other);
18  glm::vec3 min;
19  glm::vec3 max;
20  std::unique_ptr<AABB> pLeft;
21  std::unique_ptr<AABB> pRight;
22  bool isLeaf() const;
23  glm::vec3 getCenter() const;
24 };
25 
33 glm::vec3 minVector(const glm::vec3& a, const glm::vec3& b);
34 
42 glm::vec3 maxVector(const glm::vec3& a, const glm::vec3& b);
43 
48 {
49  const std::vector<std::vector<int>> heightMatrix;
50  const std::vector<std::vector<std::string>> areaMatrix;
51  const unsigned int areaSize;
52  const float heightScale;
53  const float sideUnit;
54  const float sideScale;
55 };
56 
60 std::vector<std::unique_ptr<AABB>> createMapAABB(const MapAABBData& data);
61 
73 std::unique_ptr<AABB> createAreaAABB(AABB* aabb, const int x, const int y, const int xsize, const int ysize, const MapAABBData& input, bool burgerFlip);
glm::vec3 maxVector(const glm::vec3 &a, const glm::vec3 &b)
Constructs a maximum vector from two vectors.
Definition: AABB.cpp:43
std::vector< std::unique_ptr< AABB > > createMapAABB(const MapAABBData &data)
Creates a list of AABBs trees for each area in the areaMatrix.
Definition: AABB.cpp:48
std::unique_ptr< AABB > createAreaAABB(AABB *aabb, const int x, const int y, const int xsize, const int ysize, const MapAABBData &input, bool burgerFlip)
Recursively creates an AABB tree for a single area.
Definition: AABB.cpp:61
glm::vec3 minVector(const glm::vec3 &a, const glm::vec3 &b)
Constructs a minimum vector from two vectors.
Definition: AABB.cpp:38
Axis Aligned Bounding Box data structure.
Definition: AABB.hpp:14
glm::vec3 min
Definition: AABB.hpp:18
std::unique_ptr< AABB > pRight
Definition: AABB.hpp:21
AABB(glm::vec3 min=glm::vec3(0.f), glm::vec3 max=glm::vec3(0.f), std::unique_ptr< AABB > pLeft=nullptr, std::unique_ptr< AABB > pRight=nullptr)
Definition: AABB.cpp:6
glm::vec3 getCenter() const
Definition: AABB.cpp:33
std::unique_ptr< AABB > pLeft
Definition: AABB.hpp:20
AABB & operator=(AABB &other)
Definition: AABB.cpp:19
bool isLeaf() const
Definition: AABB.cpp:28
glm::vec3 max
Definition: AABB.hpp:19
Helper struct to store all the data necessary for creating a map AABB tree.
Definition: AABB.hpp:48
const std::vector< std::vector< std::string > > areaMatrix
Matrix cell contains the name of the area for the given column (x) and row (y). This gives important ...
Definition: AABB.hpp:50
const float sideUnit
The size of the side of a tile in the original unit.
Definition: AABB.hpp:53
const std::vector< std::vector< int > > heightMatrix
Matrix cell contains the height of the tile for the given column (x) and row (y). This matrix contain...
Definition: AABB.hpp:49
const float sideScale
Percentage value of how much the side is scaled from the original unit.
Definition: AABB.hpp:54
const unsigned int areaSize
The size of the area in tiles. Width and height of the area are the same.
Definition: AABB.hpp:51
const float heightScale
Percentage value of how much the height is scaled from the original unit.
Definition: AABB.hpp:52