Open 3D Engine EMotionFX Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
MCore::AABB Class Reference

#include <AABB.h>

Public Member Functions

MCORE_INLINE AABB ()
 
MCORE_INLINE AABB (const AZ::Vector3 &minPnt, const AZ::Vector3 &maxPnt)
 
MCORE_INLINE void Init ()
 
MCORE_INLINE bool CheckIfIsValid () const
 
MCORE_INLINE void Encapsulate (const AZ::Vector3 &v)
 
MCORE_INLINE void Encapsulate (const AABB &box)
 
MCORE_INLINE void Widen (float delta)
 
MCORE_INLINE void Translate (const AZ::Vector3 &offset)
 
MCORE_INLINE bool Contains (const AZ::Vector3 &v) const
 
MCORE_INLINE bool Contains (const AABB &box) const
 
MCORE_INLINE bool Intersects (const AABB &box) const
 
MCORE_INLINE float CalcWidth () const
 
MCORE_INLINE float CalcHeight () const
 
MCORE_INLINE float CalcDepth () const
 
MCORE_INLINE float CalcVolume () const
 
MCORE_INLINE float CalcSurfaceArea () const
 
MCORE_INLINE AZ::Vector3 CalcMiddle () const
 
MCORE_INLINE AZ::Vector3 CalcExtents () const
 
MCORE_INLINE float CalcRadius () const
 
MCORE_INLINE const AZ::Vector3 & GetMin () const
 
MCORE_INLINE const AZ::Vector3 & GetMax () const
 
MCORE_INLINE void SetMin (const AZ::Vector3 &minVec)
 
MCORE_INLINE void SetMax (const AZ::Vector3 &maxVec)
 
void CalcCornerPoints (AZ::Vector3 *outPoints) const
 

Detailed Description

An axis aligned bounding box (AABB). This box is constructed out of two 3D points, a minimum and a maximum. This means the box does not rotate, but always keeps aligned each axis. Usage for this template could be for building a bounding volume around any given 3D object and use it to accelerate ray tracing or visibility tests.

Constructor & Destructor Documentation

◆ AABB() [1/2]

MCORE_INLINE MCore::AABB::AABB ( )
inline

Default constructor. Initializes the min and max point to the extremes. This means it's basically inside out at infinite size. So you are ready to start encapsulating points.

◆ AABB() [2/2]

MCORE_INLINE MCore::AABB::AABB ( const AZ::Vector3 &  minPnt,
const AZ::Vector3 &  maxPnt 
)
inline

Constructor which inits the minimum and maximum point of the box.

Parameters
minPntThe minimum point.
maxPntThe maximum point.

Member Function Documentation

◆ CalcDepth()

MCORE_INLINE float MCore::AABB::CalcDepth ( ) const
inline

Calculates and returns the depth of the box. The depth is the distance between the minimum and maximum point, along the Y-axis.

Returns
The depth of the box.

◆ CalcExtents()

MCORE_INLINE AZ::Vector3 MCore::AABB::CalcExtents ( ) const
inline

Calculates the extents of the box. This is the vector from the center to a corner of the box.

Returns
The vector containing the extents.

◆ CalcHeight()

MCORE_INLINE float MCore::AABB::CalcHeight ( ) const
inline

Calculates and returns the height of the box. The height is the distance between the minimum and maximum point, along the Z-axis.

Returns
The height of the box.

◆ CalcMiddle()

MCORE_INLINE AZ::Vector3 MCore::AABB::CalcMiddle ( ) const
inline

Calculates the center/middle of the box. This is simply done by taking the average of the minimum and maximum point along each axis.

Returns
The center (or middle) point of this box.

◆ CalcRadius()

MCORE_INLINE float MCore::AABB::CalcRadius ( ) const
inline

Calculates the radius of this box. With radius we mean the length of the vector from the center of the box to the minimum or maximum point. So if you would construct a sphere with as center the middle of this box and with a radius returned by this method, you will get the minimum sphere which exactly contains this box.

Returns
The length of the center of the box to one of the extreme points. So the minimum radius of the bounding sphere containing this box.

◆ CalcSurfaceArea()

MCORE_INLINE float MCore::AABB::CalcSurfaceArea ( ) const
inline

Calculate the surface area of the box.

Returns
The surface area.

◆ CalcVolume()

MCORE_INLINE float MCore::AABB::CalcVolume ( ) const
inline

Calculate the volume of the box. This equals width x height x depth.

Returns
The volume of the box.

◆ CalcWidth()

MCORE_INLINE float MCore::AABB::CalcWidth ( ) const
inline

Calculates and returns the width of the box. The width is the distance between the minimum and maximum point, along the X-axis.

Returns
The width of the box.

◆ CheckIfIsValid()

MCORE_INLINE bool MCore::AABB::CheckIfIsValid ( ) const
inline

Check if this is a valid AABB or not. The box is only valid if the minimum values are all smaller or equal than the maximum values.

Returns
True when the AABB is valid, otherwise false is returned.

◆ Contains() [1/2]

MCORE_INLINE bool MCore::AABB::Contains ( const AABB box) const
inline

Checks if a given AABB is COMPLETELY inside this box or not. Note that the edges/planes of this box are counted as 'inside'.

Parameters
boxThe AABB to perform the test with.
Returns
Returns true when the AABB 'b' is COMPLETELY inside this box. If it's completely or partially outside, false will be returned.

◆ Contains() [2/2]

MCORE_INLINE bool MCore::AABB::Contains ( const AZ::Vector3 &  v) const
inline

Checks if a given point is inside this box or not. Note that the edges/planes of the box are also counted as 'inside'.

Parameters
vThe vector (3D point) to perform the test with.
Returns
Returns true when the given point is inside the box, otherwise false is returned.

◆ Encapsulate() [1/2]

MCORE_INLINE void MCore::AABB::Encapsulate ( const AABB box)
inline

Encapsulate another AABB with this box. This method automatically adjusts the minimum and maximum point of the box after 'adding' the given AABB to this box.

Parameters
boxThe AABB to 'add' to this box.

◆ Encapsulate() [2/2]

MCORE_INLINE void MCore::AABB::Encapsulate ( const AZ::Vector3 &  v)

Encapsulate a point in the box. This means that the box will automatically calculate the new minimum and maximum points when needed.

Parameters
vThe vector (3D point) to 'add' to the box.

◆ GetMax()

MCORE_INLINE const AZ::Vector3 & MCore::AABB::GetMax ( ) const
inline

Get the maximum point of the box.

Returns
The maximum point of the box.

◆ GetMin()

MCORE_INLINE const AZ::Vector3 & MCore::AABB::GetMin ( ) const
inline

Get the minimum point of the box.

Returns
The minimum point of the box.

◆ Init()

MCORE_INLINE void MCore::AABB::Init ( )
inline

Initialize the box minimum and maximum points. Sets the points to floating point maximum and minimum. After calling this method you are ready to encapsulate points in it. Note, that the default constructor already calls this method. So you should only call it when you want to 'reset' the minimum and maximum points of the box.

◆ Intersects()

MCORE_INLINE bool MCore::AABB::Intersects ( const AABB box) const
inline

Checks if a given AABB partially or completely contains, so intersects, this box or not. Please note that the edges of this box are counted as 'inside'.

Parameters
boxThe AABB to perform the test with.
Returns
Returns true when the given AABB 'b' is completely or partially inside this box. Only false will be returned when the given AABB 'b' is COMPLETELY outside this box.

◆ SetMax()

MCORE_INLINE void MCore::AABB::SetMax ( const AZ::Vector3 &  maxVec)
inline

Set the maximum point of the box.

Parameters
maxVecThe vector representing the maximum point of the box.

◆ SetMin()

MCORE_INLINE void MCore::AABB::SetMin ( const AZ::Vector3 &  minVec)
inline

Set the minimum point of the box.

Parameters
minVecThe vector representing the minimum point of the box.

◆ Translate()

MCORE_INLINE void MCore::AABB::Translate ( const AZ::Vector3 &  offset)
inline

Translates the box with a given offset vector. This means the middle of the box will be moved by the given vector.

Parameters
offsetThe offset vector to translate (move) the box with.

◆ Widen()

MCORE_INLINE void MCore::AABB::Widen ( float  delta)
inline

Widen the box in all dimensions with a given number of units.

Parameters
deltaThe delta size in units to enlarge the box with. The delta value will be added to the maximum point as well as subtracted from the minimum point.

The documentation for this class was generated from the following file: