Botcraft 1.21.4
Loading...
Searching...
No Matches
AABB.hpp
Go to the documentation of this file.
1#pragma once
2
4
5namespace Botcraft
6{
7 class AABB
8 {
9 public:
10 AABB(const Vector3<double>& center_, const Vector3<double>& half_size_);
11 ~AABB();
12 Vector3<double> GetMin() const;
13 Vector3<double> GetMax() const;
14 const Vector3<double>& GetCenter() const;
15 const Vector3<double>& GetHalfSize() const;
16 /// @brief Get the closest point in the AABB from a given point
17 /// @param pos The reference point
18 /// @return Closest point to pos inside the AABB
20 /// @brief Get the volume of this AABB
21 /// @return size_x * size_y * size_z
22 double GetVolume() const;
23
24 //Return whether or not these two AABB collides
25 bool Collide(const AABB& b) const;
26
27 bool Intersect(const Vector3<double>& origin, const Vector3<double>& direction) const;
28
29 AABB& Inflate(const double d);
31
32 bool operator<(const AABB& other) const;
33 bool operator==(const AABB& other) const;
34
35 template <typename T>
36 friend AABB operator+(AABB box, const Vector3<T>& offset)
37 {
38 box.center.x += offset.x;
39 box.center.y += offset.y;
40 box.center.z += offset.z;
41
42 return box;
43 }
44
45
46 private:
49 };
50} // Botcraft
Vector3< double > GetClosestPoint(const Vector3< double > &pos) const
Get the closest point in the AABB from a given point.
Definition AABB.cpp:38
const Vector3< double > & GetHalfSize() const
Definition AABB.cpp:33
bool Intersect(const Vector3< double > &origin, const Vector3< double > &direction) const
Definition AABB.cpp:69
Vector3< double > GetMin() const
Definition AABB.cpp:18
double GetVolume() const
Get the volume of this AABB.
Definition AABB.cpp:55
bool operator==(const AABB &other) const
Definition AABB.cpp:110
AABB & Translate(const Vector3< double > &t)
Definition AABB.cpp:98
bool operator<(const AABB &other) const
Definition AABB.cpp:104
const Vector3< double > & GetCenter() const
Definition AABB.cpp:28
bool Collide(const AABB &b) const
Definition AABB.cpp:60
Vector3< double > half_size
Definition AABB.hpp:48
Vector3< double > center
Definition AABB.hpp:47
friend AABB operator+(AABB box, const Vector3< T > &offset)
Definition AABB.hpp:36
AABB & Inflate(const double d)
Definition AABB.cpp:92
Vector3< double > GetMax() const
Definition AABB.cpp:23