You.i Engine
YiAABB.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2020. All rights reserved.
2 #ifndef _YI_AABB_H_
3 #define _YI_AABB_H_
4 
5 #include "framework/YiPredef.h"
6 
7 #include <glm/fwd.hpp>
8 #include <glm/vec3.hpp>
9 
15 class CYIRay;
16 
24 class CYIAABB
25 {
26 public:
30  CYIAABB();
31 
37  CYIAABB(const glm::vec3 &rMinimumExtent, const glm::vec3 &rMaximumExtent);
38 
44  void Enlarge(const CYIAABB &box);
45 
53  glm::vec3 GetCentroid() const;
54 
58  glm::vec3 GetHalfDimensions() const;
59 
60  float GetWidth() const;
61  float GetHeight() const;
62  float GetDepth() const;
63 
69  const glm::vec3 &GetTopLeft() const;
70 
76  const glm::vec3 &GetBottomRight() const;
77 
87  bool Intersects(const CYIRay &rRay, glm::vec3 *pCollision = nullptr) const;
88 
94  bool Intersects(const CYIAABB &rOther) const;
95 
101  void SetCorners(const glm::vec3 &rMinimumExtent, const glm::vec3 &rMaximumExtent);
102 
106  CYIAABB Intersection(const CYIAABB &rOther) const;
107 
111  bool IsValid() const;
112 
116  void Transform(const glm::mat4 &transform);
117 
118  bool operator==(const CYIAABB &other) const;
119  bool operator!=(const CYIAABB &other) const;
120 
121 private:
125  void AlignToAxes();
126 
127  glm::vec3 m_Min;
128  glm::vec3 m_Max;
129 };
130 
133 #endif // _YI_AABB_H_
void SetCorners(const glm::vec3 &rMinimumExtent, const glm::vec3 &rMaximumExtent)
bool operator!=(const CYIAABB &other) const
glm::vec3 GetHalfDimensions() const
bool operator==(const CYIAABB &other) const
glm::vec3 GetCentroid() const
bool IsValid() const
CYIAABB Intersection(const CYIAABB &rOther) const
const glm::vec3 & GetBottomRight() const
float GetWidth() const
Encapsulates the origin and direction points of a ray.
Definition: YiRay.h:32
void Enlarge(const CYIAABB &box)
This class represents an Axis-Aligned Bounding Box.
Definition: YiAABB.h:24
const glm::vec3 & GetTopLeft() const
void Transform(const glm::mat4 &transform)
float GetDepth() const
float GetHeight() const
bool Intersects(const CYIRay &rRay, glm::vec3 *pCollision=nullptr) const