aabb Struct Template
Axis-Aligned Bounding Box for spatial culling and collision detection. More...
Declaration
Public Constructors Index
template <helios::math::Numeric T> | |
| constexpr | aabb () noexcept |
|
Constructs an empty AABB with inverted min/max values. More... | |
template <helios::math::Numeric T> | |
| constexpr | aabb (const T minX, const T minY, const T minZ, const T maxX, const T maxY, const T maxZ) noexcept |
|
Constructs an AABB from individual component values. More... | |
template <helios::math::Numeric T> | |
| constexpr | aabb (const helios::math::vec3< T > min, const helios::math::vec3< T > max) noexcept |
|
Constructs an AABB from two corner points. More... | |
Public Member Functions Index
template <helios::math::Numeric T> | |
| constexpr auto | min () const noexcept -> const helios::math::vec3< T > & |
|
Returns the minimum corner point of the AABB. More... | |
template <helios::math::Numeric T> | |
| constexpr auto | max () const noexcept -> const helios::math::vec3< T > & |
|
Returns the maximum corner point of the AABB. More... | |
template <helios::math::Numeric T> | |
| constexpr auto | center () const noexcept -> helios::math::vec3< T > |
|
Computes the center point of the AABB. More... | |
template <helios::math::Numeric T> | |
| constexpr auto | size () const noexcept -> helios::math::vec3< T > |
|
Computes the size of the AABB over all axes. More... | |
template <helios::math::Numeric T> | |
| constexpr bool | contains (const helios::math::aabb< T > &box) const noexcept |
|
Checks if this AABB fully contains another AABB. More... | |
template <helios::math::Numeric T> | |
| constexpr bool | contains (const helios::math::vec3< T > &point) const noexcept |
template <helios::math::Numeric T> | |
| constexpr bool | intersects (const helios::math::aabb< T > &box) const noexcept |
|
Checks if this AABB intersects or touches another AABB. More... | |
template <helios::math::Numeric T> | |
| constexpr auto | translate (const helios::math::vec3< T > &v) const noexcept -> helios::math::aabb< T > |
|
Translates the AABB by a given vector. More... | |
template <helios::math::Numeric T> | |
| void | add (const helios::math::vec3< T > &point) noexcept |
|
Expands the AABB to include a given point. More... | |
template <helios::math::Numeric T> | |
| auto | applyTransform (const mat4< T > &mat) const noexcept -> aabb< T > |
|
Transforms the AABB by a 4x4 transformation matrix. More... | |
Private Member Attributes Index
template <helios::math::Numeric T> | |
| helios::math::vec3< T > | min_ |
|
Minimum corner point of the bounding box. More... | |
template <helios::math::Numeric T> | |
| helios::math::vec3< T > | max_ |
|
Maximum corner point of the bounding box. More... | |
Description
Axis-Aligned Bounding Box for spatial culling and collision detection.
An AABB is defined by two corner points: a minimum and maximum point in 3D space. Depending on the use case, the box is aligned to the world or local coordinate axes.
Common use cases include frustum culling, broad-phase collision detection, and spatial partitioning in scene graphs.
- Template Parameters
-
T The numeric type of the vector components (typically `float` or `double`).
- See Also
[Gla95, pp. 548-550] Glassner, A. (1995). Graphics Gems
- See Also
[DP11, pp. 304-311] Dunn, F., & Parberry, I. (2011). 3D Math Primer for Graphics and Game Development
Definition at line 34 of file aabb.ixx.
Public Constructors
aabb()
| inline constexpr noexcept |
Constructs an empty AABB with inverted min/max values.
The AABB is initialized with min set to the maximum representable value and max set to the minimum representable value. This allows the first `add()` call to properly establish the initial bounds.
Definition at line 60 of file aabb.ixx.
Referenced by helios::math::aabb< float >::applyTransform.
aabb()
| inline constexpr noexcept |
Constructs an AABB from individual component values.
- Parameters
-
minX Minimum X coordinate.
minY Minimum Y coordinate.
minZ Minimum Z coordinate.
maxX Maximum X coordinate.
maxY Maximum Y coordinate.
maxZ Maximum Z coordinate.
aabb()
| inline constexpr noexcept |
Constructs an AABB from two corner points.
- Parameters
-
min The minimum corner point (smallest x, y, z).
max The maximum corner point (largest x, y, z).
Definition at line 86 of file aabb.ixx.
Public Member Functions
add()
| inline noexcept |
Expands the AABB to include a given point.
Updates the minimum and maximum bounds to ensure the specified point lies within the AABB. Each component is compared independently:
- If a component of the point is smaller than the current minimum, the minimum is updated.
- If a component of the point is larger than the current maximum, the maximum is updated.
- Parameters
-
point The 3D point to include in the bounding box.
Definition at line 209 of file aabb.ixx.
applyTransform()
| inline nodiscard noexcept |
Transforms the AABB by a 4x4 transformation matrix.
Applies a transformation matrix to the AABB and returns a new axis-aligned bounding box that fully contains the transformed original. This method preserves the axis-aligned property by computing new min/max bounds from the transformed corners.
The algorithm efficiently transforms only the min/max corners instead of all 8 vertices, using Arvo's optimization technique from Graphics Gems.
- Parameters
-
mat The 4x4 transformation matrix to apply.
- Returns
A new AABB that fully contains the transformed bounding box.
- See Also
[Gla95, pp. 548-550] "Transforming Axis-Aligned Bounding Boxes" by James Arvo
Definition at line 235 of file aabb.ixx.
center()
| inline nodiscard constexpr noexcept |
Computes the center point of the AABB.
- Returns
The center point, calculated as `(min + max) / 2`.
Definition at line 114 of file aabb.ixx.
contains()
| inline nodiscard constexpr noexcept |
Checks if this AABB fully contains another AABB.
Tests whether all corners of the specified bounding box lie within the bounds of this AABB. Both minimum and maximum corners must be contained.
- Parameters
-
box The AABB to test for containment.
- Returns
True if the specified box is fully contained within this AABB, false otherwise.
Definition at line 137 of file aabb.ixx.
Referenced by helios::engine::runtime::spawn::behavior::placements::AxisSpawnPlacer::getPosition.
contains()
| inline nodiscard constexpr noexcept |
Checks if this AABB fully contains the specified point.
- Parameters
-
point The vec3 to test for containment.
- Returns
True if the specified point is fully contained within this AABB, otherwise false.
Definition at line 154 of file aabb.ixx.
intersects()
| inline nodiscard constexpr noexcept |
Checks if this AABB intersects or touches another AABB.
- Parameters
-
box The AABB to test for intersection.
- Returns
True if the specified box intersects this AABB, false otherwise.
Definition at line 166 of file aabb.ixx.
Referenced by helios::engine::modules::physics::collision::systems::GridCollisionDetectionSystem::solveCell.
max()
| inline nodiscard constexpr noexcept |
Returns the maximum corner point of the AABB.
- Returns
Const reference to the maximum corner point.
Definition at line 105 of file aabb.ixx.
Referenced by helios::engine::runtime::spawn::behavior::placements::AxisSpawnPlacer::getPosition, helios::engine::runtime::spawn::behavior::placements::ColumnSpawnPlacer::getPosition, helios::engine::runtime::spawn::behavior::placements::RandomSpawnPlacer::getPosition, helios::math::operator* and helios::engine::modules::physics::collision::systems::GridCollisionDetectionSystem::worldBoundsToGridBounds.
min()
| inline nodiscard constexpr noexcept |
Returns the minimum corner point of the AABB.
- Returns
Const reference to the minimum corner point.
Definition at line 96 of file aabb.ixx.
Referenced by helios::engine::runtime::spawn::behavior::placements::AxisSpawnPlacer::getPosition, helios::engine::runtime::spawn::behavior::placements::ColumnSpawnPlacer::getPosition, helios::engine::runtime::spawn::behavior::placements::RandomSpawnPlacer::getPosition, helios::math::operator* and helios::engine::modules::physics::collision::systems::GridCollisionDetectionSystem::worldBoundsToGridBounds.
size()
| inline nodiscard constexpr noexcept |
Computes the size of the AABB over all axes.
- Returns
A vector representing the width, height, and depth of the AABB.
Definition at line 123 of file aabb.ixx.
Referenced by helios::engine::runtime::spawn::behavior::placements::AxisSpawnPlacer::getPosition and helios::engine::runtime::spawn::behavior::placements::ColumnSpawnPlacer::getPosition.
translate()
| inline nodiscard constexpr noexcept |
Translates the AABB by a given vector.
Creates a new AABB by adding the components of the given translation vector to the minimum and maximum corner points of the current AABB.
- Parameters
-
v The translation vector to apply to the AABB.
- Returns
A new AABB translated by the given vector.
Definition at line 191 of file aabb.ixx.
Referenced by helios::engine::runtime::spawn::behavior::placements::AxisSpawnPlacer::getPosition and helios::math::operator+.
Private Member Attributes
max_
|
Maximum corner point of the bounding box.
Contains the largest x, y, and z coordinates across all points within the AABB.
Definition at line 49 of file aabb.ixx.
min_
|
Minimum corner point of the bounding box.
Contains the smallest x, y, and z coordinates across all points within the AABB.
Definition at line 42 of file aabb.ixx.
The documentation for this struct was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.