20 #ifndef ANTKEEPER_GEOM_AABB_HPP
21 #define ANTKEEPER_GEOM_AABB_HPP
85 vector_type min_point = {std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity()};
86 vector_type max_point = {-std::numeric_limits<T>::infinity(), -std::numeric_limits<T>::infinity(), -std::numeric_limits<T>::infinity()};
88 for (std::size_t i = 0; i < 8; ++i)
92 for (std::size_t j = 0; j < 3; ++j)
94 min_point[j] = std::min<T>(min_point[j], transformed_corner[j]);
95 max_point[j] = std::max<T>(max_point[j], transformed_corner[j]);
99 return {min_point, max_point};
105 vector_type min_point = {std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity(), std::numeric_limits<T>::infinity()};
106 vector_type max_point = {-std::numeric_limits<T>::infinity(), -std::numeric_limits<T>::infinity(), -std::numeric_limits<T>::infinity()};
108 for (std::size_t i = 0; i < 8; ++i)
113 for (std::size_t j = 0; j < 3; ++j)
115 min_point[j] = std::min<T>(min_point[j], transformed_corner[j]);
116 max_point[j] = std::max<T>(max_point[j], transformed_corner[j]);
120 return {min_point, max_point};
125 min_point(min_point),
185 if (point.x() < min_point.x() || point.x() > max_point.x())
187 if (point.y() < min_point.y() || point.y() > max_point.y())
189 if (point.z() < min_point.z() || point.z() > max_point.z())
199 ((
index >> 2) & 1) ? max_point[0] : min_point[0],
200 ((
index >> 1) & 1) ? max_point[1] : min_point[1],
201 ((
index >> 0) & 1) ? max_point[2] : min_point[2]
Abstract base class for bounding volumes.
bounding_volume_type
Enumerates bounding volume types.
@ aabb
Indicates the bounding volume is an axis-aligned bounding box.
constexpr matrix< T, P, M > mul(const matrix< T, N, M > &a, const matrix< T, P, N > &b) noexcept
Multiplies two matrices.
@ index
General purpose index (uint)
Axis-aligned bounding box.
vector_type corner(std::size_t index) const noexcept
Returns the position of the specified corner.
static aabb transform(const aabb &a, const matrix_type &m)
Transforms an AABB.
aabb(const vector_type &min_point, const vector_type &max_point)
virtual bool intersects(const sphere< T > &sphere) const
Tests for intersection between this bounding volume and a bounding sphere.
static aabb transform(const aabb &a, const transform_type &t)
Transforms an AABB.
math::vector< T, 3 > vector_type
virtual bounding_volume_type get_bounding_volume_type() const
Returns the enumerated type of this bounding volume.
virtual bool contains(const sphere< T > &sphere) const
Tests whether this bounding volume contains a sphere.
virtual bool contains(const aabb< T > &aabb) const
Tests whether this bounding volume contains an axis-aligned bounding box.
math::matrix< T, 4, 4 > matrix_type
math::transform< T > transform_type
virtual bool contains(const vector_type &point) const
Tests whether this bounding volume contains a point.
virtual bool intersects(const aabb< T > &aabb) const
Tests for intersection between this bounding volume and an axis-aligned bounding box.
n by m column-major matrix.
constexpr element_type & x() noexcept
Returns a reference to the first element.
constexpr element_type & y() noexcept
Returns a reference to the second element.
constexpr element_type & z() noexcept
Returns a reference to the third element.