MAGE  v0.171.0
Matthias Advanced Game Engine
mage::AABB Class Reference

#include <bounding_volume.hpp>

Public Member Functions

 AABB () noexcept
 
 AABB (const Point3 &p) noexcept
 
 AABB (FXMVECTOR p) noexcept
 
 AABB (const Point3 &p_min, const Point3 &p_max) noexcept
 
 AABB (FXMVECTOR p_min, FXMVECTOR p_max) noexcept
 
 AABB (const AABB &aabb) noexcept=default
 
 AABB (AABB &&aabb) noexcept=default
 
 AABB (const BoundingSphere &sphere) noexcept
 
 ~AABB ()=default
 
AABBoperator= (const AABB &aabb) noexcept=default
 
AABBoperator= (AABB &&aabb) noexcept=default
 
const XMVECTOR XM_CALLCONV MinPoint () const noexcept
 
const XMVECTOR XM_CALLCONV MaxPoint () const noexcept
 
const std::pair< XMVECTOR, XMVECTOR > XM_CALLCONV MinAndMaxPointAlongNormal (FXMVECTOR n) const noexcept
 
const XMVECTOR XM_CALLCONV MinPointAlongNormal (FXMVECTOR n) const noexcept
 
const XMVECTOR XM_CALLCONV MaxPointAlongNormal (FXMVECTOR n) const noexcept
 
const XMVECTOR XM_CALLCONV Centroid () const noexcept
 
const XMVECTOR XM_CALLCONV Radius () const noexcept
 
const XMVECTOR XM_CALLCONV Diagonal () const noexcept
 
bool Encloses (const Point3 &point) const noexcept
 
bool EnclosesStrict (const Point3 &point) const noexcept
 
bool XM_CALLCONV Encloses (FXMVECTOR point) const noexcept
 
bool XM_CALLCONV EnclosesStrict (FXMVECTOR point) const noexcept
 
bool Encloses (const AABB &aabb) const noexcept
 
bool EnclosesStrict (const AABB &aabb) const noexcept
 
bool Encloses (const BoundingSphere &sphere) const noexcept
 
bool EnclosesStrict (const BoundingSphere &sphere) const noexcept
 
bool Overlaps (const AABB &aabb) const noexcept
 
bool OverlapsStrict (const AABB &aabb) const noexcept
 
bool Overlaps (const BoundingSphere &sphere) const noexcept
 
bool OverlapsStrict (const BoundingSphere &sphere) const noexcept
 
bool operator== (const AABB &aabb) const noexcept
 
bool operator!= (const AABB &aabb) const noexcept
 

Static Public Member Functions

static const AABB XM_CALLCONV Union (const AABB &aabb, const Point3 &point) noexcept
 
template<typename VertexT >
static const AABB XM_CALLCONV Union (const AABB &aabb, const VertexT &vertex) noexcept
 
static const AABB XM_CALLCONV Union (const AABB &aabb, FXMVECTOR point) noexcept
 
static const AABB XM_CALLCONV Union (const AABB &aabb1, const AABB &aabb2) noexcept
 
static const AABB XM_CALLCONV Overlap (const AABB &aabb1, const AABB &aabb2) noexcept
 
static const AABB XM_CALLCONV OverlapStrict (const AABB &aabb1, const AABB &aabb2) noexcept
 
static const AABB XM_CALLCONV Minimum () noexcept
 
static const AABB XM_CALLCONV Maximum () noexcept
 

Private Attributes

XMVECTOR m_min
 
XMVECTOR m_max
 

Detailed Description

A class of Axis-Aligned Bounding Boxes (AABBs).

Constructor & Destructor Documentation

◆ AABB() [1/8]

mage::AABB::AABB ( )
noexcept

Constructs an AABB.

◆ AABB() [2/8]

mage::AABB::AABB ( const Point3 p)
explicitnoexcept

Constructs an AABB of the given point.

Parameters
[in]pA reference to the point.

◆ AABB() [3/8]

mage::AABB::AABB ( FXMVECTOR  p)
explicitnoexcept

Constructs an AABB of the given point.

Parameters
[in]pThe point.

◆ AABB() [4/8]

mage::AABB::AABB ( const Point3 p_min,
const Point3 p_max 
)
noexcept

Constructs an AABB of the given extents.

Parameters
[in]p_minA reference to the minimum extents.
[in]p_maxA reference to the maximum extents.

◆ AABB() [5/8]

mage::AABB::AABB ( FXMVECTOR  p_min,
FXMVECTOR  p_max 
)
noexcept

Constructs an AABB of the given extents.

Parameters
[in]p_minThe minimum extents.
[in]p_maxThe maximum extents.

◆ AABB() [6/8]

mage::AABB::AABB ( const AABB aabb)
defaultnoexcept

Constructs an AABB from the given AABB.

Parameters
[in]aabbA reference to the AABB to copy.

◆ AABB() [7/8]

mage::AABB::AABB ( AABB &&  aabb)
defaultnoexcept

Constructs an AABB by moving the given AABB.

Parameters
[in]aabbA reference to the AABB to move.

◆ AABB() [8/8]

mage::AABB::AABB ( const BoundingSphere sphere)
explicitnoexcept

Constructs an AABB of the given bounding sphere.

Parameters
[in]sphereA reference to the bounding sphere.

◆ ~AABB()

mage::AABB::~AABB ( )
default

Destructs this AABB.

Member Function Documentation

◆ Centroid()

const XMVECTOR XM_CALLCONV mage::AABB::Centroid ( ) const
noexcept

Returns the centroid of this AABB.

Returns
The centroid of this AABB.

◆ Diagonal()

const XMVECTOR XM_CALLCONV mage::AABB::Diagonal ( ) const
noexcept

Returns the diagonal of this AABB.

Returns
The diagonal of this AABB.

◆ Encloses() [1/4]

bool mage::AABB::Encloses ( const Point3 point) const
noexcept

Checks whether this AABB completely encloses the given point.

Parameters
[in]pointA reference to the point.
Returns
true if this AABB completely encloses point. false otherwise.
Note
This is a full coverage test of a point with regard to an AABB.

◆ Encloses() [2/4]

bool XM_CALLCONV mage::AABB::Encloses ( FXMVECTOR  point) const
noexcept

Checks whether this AABB completely encloses the given point.

Parameters
[in]pointA reference to the point.
Returns
true if this AABB completely encloses point. false otherwise.
Note
This is a full coverage test of a point with regard to an AABB.

◆ Encloses() [3/4]

bool mage::AABB::Encloses ( const AABB aabb) const
noexcept

Checks whether this AABB completely encloses the given AABB.

Parameters
[in]aabbA reference to the AABB.
Returns
true if this AABB completely encloses aabb. false otherwise.
Note
This is a full coverage test of an AABB with regard to an AABB.

◆ Encloses() [4/4]

bool mage::AABB::Encloses ( const BoundingSphere sphere) const
noexcept

Checks whether this AABB completely encloses the given bounding sphere.

Parameters
[in]sphereA reference to the bounding sphere.
Returns
true if this AABB completely encloses sphere. false otherwise.
Note
This is a full coverage test of a bounding sphere with regard to an AABB.

◆ EnclosesStrict() [1/4]

bool mage::AABB::EnclosesStrict ( const Point3 point) const
noexcept

Checks whether this AABB completely, strictly encloses the given point.

Parameters
[in]pointA reference to the point.
Returns
true if this AABB completely, strictly encloses point. false otherwise.
Note
This is a full coverage test of a point with regard to an AABB.

◆ EnclosesStrict() [2/4]

bool XM_CALLCONV mage::AABB::EnclosesStrict ( FXMVECTOR  point) const
noexcept

Checks whether this AABB completely, strictly encloses the given point.

Parameters
[in]pointA reference to the point.
Returns
true if this AABB completely, strictly encloses point. false otherwise.
Note
This is a full coverage test of a point with regard to an AABB.

◆ EnclosesStrict() [3/4]

bool mage::AABB::EnclosesStrict ( const AABB aabb) const
noexcept

Checks whether this AABB completely, strictly encloses the given AABB.

Parameters
[in]aabbA reference to the AABB.
Returns
true if this AABB completely, strictly encloses aabb. false otherwise.
Note
This is a full coverage test of an AABB with regard to an AABB.

◆ EnclosesStrict() [4/4]

bool mage::AABB::EnclosesStrict ( const BoundingSphere sphere) const
noexcept

Checks whether this AABB completely, strictly encloses the given bounding sphere.

Parameters
[in]sphereA reference to the bounding sphere.
Returns
true if this AABB completely, strictly encloses sphere. false otherwise.
Note
This is a full coverage test of a bounding sphere with regard to an AABB.

◆ Maximum()

static const AABB XM_CALLCONV mage::AABB::Maximum ( )
staticnoexcept

Returns the maximum AABB (i.e. the AABB that is invariant for union operations).

Returns
The maximum AABB.

◆ MaxPoint()

const XMVECTOR XM_CALLCONV mage::AABB::MaxPoint ( ) const
noexcept

Returns the maximum point of this AABB.

Returns
The maximum point of this AABB.

◆ MaxPointAlongNormal()

const XMVECTOR XM_CALLCONV mage::AABB::MaxPointAlongNormal ( FXMVECTOR  n) const
noexcept

Returns the maximum point of this AABB along a given normal.

Parameters
[in]nThe normal.
Returns
The minimum point of this AABB along n.

◆ MinAndMaxPointAlongNormal()

const std::pair< XMVECTOR, XMVECTOR > XM_CALLCONV mage::AABB::MinAndMaxPointAlongNormal ( FXMVECTOR  n) const
noexcept

Returns the minimum and maximum point of this AABB along a given normal.

Parameters
[in]nThe normal.
Returns
A pair containing the minimum and maximum point of this AABB along n.

◆ Minimum()

static const AABB XM_CALLCONV mage::AABB::Minimum ( )
staticnoexcept

Returns the minimum AABB (i.e. the AABB that is variant for union operations).

Returns
The minimum AABB.

◆ MinPoint()

const XMVECTOR XM_CALLCONV mage::AABB::MinPoint ( ) const
noexcept

Returns the minimum point of this AABB.

Returns
The minimum point of this AABB.

◆ MinPointAlongNormal()

const XMVECTOR XM_CALLCONV mage::AABB::MinPointAlongNormal ( FXMVECTOR  n) const
noexcept

Returns the minimum point of this AABB along a given normal.

Parameters
[in]nThe normal.
Returns
The minimum point of this AABB along n.

◆ operator!=()

bool mage::AABB::operator!= ( const AABB aabb) const
noexcept

Checks whether the given AABB is not equal to this AABB.

Parameters
[in]aabbA reference to the AABB.
Returns
true if the given AABB is equal to this AABB. false otherwise.

◆ operator=() [1/2]

AABB& mage::AABB::operator= ( const AABB aabb)
defaultnoexcept

Copies the given AABB to this AABB.

Parameters
[in]aabbA reference to the AABB to copy.
Returns
A reference to the copy of the given AABB (i.e. this AABB).

◆ operator=() [2/2]

AABB& mage::AABB::operator= ( AABB &&  aabb)
defaultnoexcept

Moves the given AABB to this AABB.

Parameters
[in]aabbA reference to the AABB to move.
Returns
A reference to the moved AABB (i.e. this AABB).

◆ operator==()

bool mage::AABB::operator== ( const AABB aabb) const
noexcept

Checks whether the given AABB is equal to this AABB.

Parameters
[in]aabbA reference to the AABB.
Returns
true if the given AABB is equal to this AABB. false otherwise.

◆ Overlap()

static const AABB XM_CALLCONV mage::AABB::Overlap ( const AABB aabb1,
const AABB aabb2 
)
staticnoexcept

Returns the overlap AABB of the two given AABBs.

Parameters
[in]aabb1A reference to the first AABB.
[in]aabb2A reference to the second AABB.
Returns
The identity AABB in case of no overlap.
The overlap AABB of aabb1 and aabb2.

◆ Overlaps() [1/2]

bool mage::AABB::Overlaps ( const AABB aabb) const
noexcept

Checks whether this AABB overlaps the given AABB.

Parameters
[in]aabbA reference to the AABB.
Returns
true if this AABB overlaps aabb. false otherwise.
Note
This is a (partial or full) coverage test of an AABB with regard to an AABB.

◆ Overlaps() [2/2]

bool mage::AABB::Overlaps ( const BoundingSphere sphere) const
noexcept

Checks whether this AABB overlaps the given bounding sphere.

Parameters
[in]sphereA reference to the bounding sphere.
Returns
true if this AABB overlaps sphere. false otherwise.
Note
This is a (partial or full) coverage test of a bounding sphere with regard to an AABB.

◆ OverlapsStrict() [1/2]

bool mage::AABB::OverlapsStrict ( const AABB aabb) const
noexcept

Checks whether this AABB strictly overlaps the given AABB.

Parameters
[in]aabbA reference to the AABB.
Returns
true if this AABB strictly overlaps aabb. false otherwise.
Note
This is a (partial or full) coverage test of an AABB with regard to an AABB.

◆ OverlapsStrict() [2/2]

bool mage::AABB::OverlapsStrict ( const BoundingSphere sphere) const
noexcept

Checks whether this AABB strictly overlaps the given bounding sphere.

Parameters
[in]sphereA reference to the bounding sphere.
Returns
true if this AABB strictly overlaps sphere. false otherwise.
Note
This is a (partial or full) coverage test of a bounding sphere with regard to an AABB.

◆ OverlapStrict()

static const AABB XM_CALLCONV mage::AABB::OverlapStrict ( const AABB aabb1,
const AABB aabb2 
)
staticnoexcept

Returns the strict overlap AABB of the two given AABBs.

Parameters
[in]aabb1A reference to the first AABB.
[in]aabb2A reference to the second AABB.
Returns
The identity AABB in case of no strict overlap.
The strict overlap AABB of aabb1 and aabb2.

◆ Radius()

const XMVECTOR XM_CALLCONV mage::AABB::Radius ( ) const
noexcept

Returns the radius of this AABB.

Returns
The radius of this AABB.

◆ Union() [1/4]

static const AABB XM_CALLCONV mage::AABB::Union ( const AABB aabb,
const Point3 point 
)
staticnoexcept

Returns the union AABB of the given AABB and the given point.

Parameters
[in]aabbA reference to the AABB.
[in]pointA reference to the point.
Returns
The union AABB of aabb and point.

◆ Union() [2/4]

template<typename VertexT >
static const AABB XM_CALLCONV mage::AABB::Union ( const AABB aabb,
const VertexT &  vertex 
)
staticnoexcept

Returns the union AABB of the given AABB and the given vertex.

Template Parameters
VertexTThe vertex type.
Parameters
[in]aabbA reference to the AABB.
[in]vertexA reference to the VertexT.
Returns
The union AABB of aabb and vertex.

◆ Union() [3/4]

static const AABB XM_CALLCONV mage::AABB::Union ( const AABB aabb,
FXMVECTOR  point 
)
staticnoexcept

Returns the union AABB of the given AABB and the given point.

Parameters
[in]aabbA reference to the AABB.
[in]pointA reference to the point.
Returns
The union AABB of aabb and point.

◆ Union() [4/4]

static const AABB XM_CALLCONV mage::AABB::Union ( const AABB aabb1,
const AABB aabb2 
)
staticnoexcept

Returns the union AABB of the two given AABBs.

Parameters
[in]aabb1A reference to the first AABB.
[in]aabb2A reference to the second AABB.
Returns
The union AABB of aabb1 and aabb2.

Member Data Documentation

◆ m_max

XMVECTOR mage::AABB::m_max
private

The maximum extents of this AABB.

◆ m_min

XMVECTOR mage::AABB::m_min
private

The minimum extents of this AABB.