Raito 0.1
Loading...
Searching...
No Matches
AABB.h
Go to the documentation of this file.
1#pragma once
3
4namespace Raito::Math
5{
6 class AABB
7 {
8 public:
10 AABB();
11
15 AABB(const V3& center, glm::float32_t radius);
16
18 AABB(const V3& p1, const V3& p2);
19
20 AABB(const AABB& aabb);
21 ~AABB() = default;
22
24 void SetNull() { m_Min = V3(1.0); m_Max = V3(-1.0); }
25
27 NODISCARD bool IsNull() const { return m_Min.x > m_Max.x || m_Min.y > m_Max.y || m_Min.z > m_Max.z; }
28
30 void Extend(glm::float32_t val);
31
33 void Extend(const V3& p);
34
39 void Extend(const V3& center, glm::float32_t radius);
40
42 void Extend(const AABB& aabb);
43
44 void Extend(const V3* pointsArray, int numCount);
45
49 void ExtendDisk(const V3& center, const V3& normal,
50 glm::float32_t radius);
51
53 void Translate(const V3& v);
54
55
56 void Scale(const V3& scale);
57
62 void Scale(const V3& scale, const V3& origin);
63
65 NODISCARD V3 GetCenter() const;
66
69 NODISCARD V3 GetDiagonal() const;
70
73 NODISCARD glm::float32_t GetLongestEdge() const;
74
77 NODISCARD glm::float32_t GetShortestEdge() const;
78
80 NODISCARD V3 GetMin() const { return m_Min; }
81
83 NODISCARD V3 GetMax() const { return m_Max; }
84
87 NODISCARD bool Overlaps(const AABB& bb) const;
88
94
101 NODISCARD bool IsSimilarTo(const AABB& b, glm::float32_t diff = 0.5) const;
102
104
107 NODISCARD V3 Size() const;
108
110
112 NODISCARD V3 HalfSize() const;
113
114 NODISCARD V3 GetExtent() const;
115
116 private:
117
118 V3 m_Min;
119 V3 m_Max;
120
121 };
122}
#define NODISCARD
Definition Common.h:80
Definition AABB.h:7
NODISCARD bool IsNull() const
Returns true if AABB is NULL (not set).
Definition AABB.h:27
NODISCARD V3 GetMin() const
Retrieves the AABB's minimum point.
Definition AABB.h:80
IntersectionType
Type returned from call to intersect.
Definition AABB.h:90
@ INTERSECT
Definition AABB.h:90
@ INSIDE
Definition AABB.h:90
@ OUTSIDE
Definition AABB.h:90
NODISCARD glm::float32_t GetShortestEdge() const
Definition AABB.cpp:111
void Scale(const V3 &scale)
Definition AABB.cpp:136
NODISCARD V3 GetMax() const
Retrieves the AABB's maximum point.
Definition AABB.h:83
NODISCARD IntersectionType Intersect(const AABB &bb) const
Definition AABB.cpp:175
NODISCARD V3 GetExtent() const
Definition AABB.cpp:226
NODISCARD V3 GetDiagonal() const
Definition AABB.cpp:97
NODISCARD V3 HalfSize() const
[similarOverload: Size]
Definition AABB.cpp:221
NODISCARD bool IsSimilarTo(const AABB &b, glm::float32_t diff=0.5) const
Definition AABB.cpp:198
NODISCARD bool Overlaps(const AABB &bb) const
Definition AABB.cpp:160
NODISCARD glm::float32_t GetLongestEdge() const
Definition AABB.cpp:106
AABB()
Builds a null AABB.
Definition AABB.cpp:6
NODISCARD V3 Size() const
Returns the side lengths of this AABB in x, y and z directions.
Definition AABB.cpp:216
void ExtendDisk(const V3 &center, const V3 &normal, glm::float32_t radius)
Definition AABB.cpp:86
void Extend(glm::float32_t val)
Extend the bounding box on all sides by val.
Definition AABB.cpp:31
void Translate(const V3 &v)
Translates AABB by vector v.
Definition AABB.cpp:127
void SetNull()
Set the AABB as NULL (not set).
Definition AABB.h:24
NODISCARD V3 GetCenter() const
Retrieves the center of the AABB.
Definition AABB.cpp:116
Definition AABB.cpp:5
glm::vec3 V3
3D Vector; 32 bit floating point components
Definition MathTypes.h:47