You.i Engine
YiAABB.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2017. 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 
14 
15 class CYIRay;
16 
24 class CYIAABB
25 {
26 public:
30  CYIAABB();
31 
39  CYIAABB(const glm::vec3 &rMinimumExtent, const glm::vec3 &rMaximumExtent);
40 
46  void Enlarge(const CYIAABB &box);
47 
55  glm::vec3 GetCentroid() const;
56 
60  glm::vec3 GetHalfDimensions() const;
61 
62  float GetWidth() const;
63  float GetHeight() const;
64  float GetDepth() const;
65 
71  const glm::vec3 &GetTopLeft() const;
72 
78  const glm::vec3 &GetBottomRight() const;
79 
87  bool Intersects(const CYIRay &rRay, glm::vec3 *pCollision = nullptr) const;
88 
94  bool Intersects(const CYIAABB &rOther) const;
95 
103  void SetCorners(const glm::vec3 &rMinimumExtent, const glm::vec3 &rMaximumExtent);
104 
108  CYIAABB Intersection(const CYIAABB &rOther) const;
109 
113  bool IsValid() const;
114 
118  void Transform(const glm::mat4 &transform);
119 
120  bool operator==(const CYIAABB &other) const;
121  bool operator!=(const CYIAABB &other) const;
122 
123 private:
127  void AlignToAxes();
128 
129  glm::vec3 m_Min;
130  glm::vec3 m_Max;
131 };
132 
135 #endif // _YI_AABB_H_
const glm::vec3 & GetBottomRight() const
bool operator==(const CYIAABB &other) const
bool IsValid() const
void SetCorners(const glm::vec3 &rMinimumExtent, const glm::vec3 &rMaximumExtent)
float GetWidth() const
const glm::vec3 & GetTopLeft() const
glm::vec3 GetCentroid() const
Encapsulates the origin and direction points of a ray.
Definition: YiRay.h:33
void Enlarge(const CYIAABB &box)
glm::vec3 GetHalfDimensions() const
float GetHeight() const
This class represents an Axis-Aligned Bounding Box.
Definition: YiAABB.h:24
bool Intersects(const CYIRay &rRay, glm::vec3 *pCollision=nullptr) const
CYIAABB Intersection(const CYIAABB &rOther) const
void Transform(const glm::mat4 &transform)
bool operator!=(const CYIAABB &other) const
float GetDepth() const