47 for (
size_t i = 0; i < 3; ++i)
49 output[i] = std::clamp(pos[i], min[i], max[i]);
71 double tmin = -std::numeric_limits<float>::max();
72 double tmax = std::numeric_limits<float>::max();
77 for (
int i = 0; i < 3; ++i)
79 if (direction[i] != 0.0)
81 double ti1 = t1[i] / direction[i];
82 double ti2 = t2[i] / direction[i];
84 tmin = std::max(tmin, std::min(ti1, ti2));
85 tmax = std::min(tmax, std::max(ti1, ti2));
Vector3< double > GetClosestPoint(const Vector3< double > &pos) const
Get the closest point in the AABB from a given point.
const Vector3< double > & GetHalfSize() const
bool Intersect(const Vector3< double > &origin, const Vector3< double > &direction) const
Vector3< double > GetMin() const
double GetVolume() const
Get the volume of this AABB.
bool operator==(const AABB &other) const
AABB & Translate(const Vector3< double > &t)
bool operator<(const AABB &other) const
const Vector3< double > & GetCenter() const
bool Collide(const AABB &b) const
Vector3< double > half_size
AABB & Inflate(const double d)
Vector3< double > GetMax() const
AABB(const Vector3< double > ¢er_, const Vector3< double > &half_size_)