SUNENGINE 0.0.2
A simple and bright C++ game engine.
 
Loading...
Searching...
No Matches
CollisionVolumeAABB Class Reference

Represents an axis-aligned bounding box (AABB) collision volume. More...

#include <CollisionVolumeAABB.h>

Inheritance diagram for CollisionVolumeAABB:
Inheritance graph

Public Member Functions

 CollisionVolumeAABB (const CollisionVolumeAABB &)
 
CollisionVolumeAABBoperator= (const CollisionVolumeAABB &)
 
void ComputeData (Model *mod, const Matrix &mat) override
 Computes the collision data for the AABB from a model and transformation matrix.
 
void ComputeData (const CollisionVolumeBSphere &bsphere)
 Computes the AABB from a bounding sphere.
 
void ComputeDataFromMinMax (const Vect &min, const Vect &max)
 Sets the AABB from explicit min and max points.
 
void Enclose (const CollisionVolumeAABB &other)
 Expands this AABB to enclose another AABB.
 
const Vect & GetMin () const
 Gets the minimum point of the AABB.
 
const Vect & GetMax () const
 Gets the maximum point of the AABB.
 
Model * GetModel () const
 Gets the model associated with this AABB.
 
void DebugView (const Vect &col) const override
 Visualizes the AABB for debugging purposes.
 
bool IntersectAccept (const CollisionVolume &other) const override
 Accepts a collision test with another collision volume (double dispatch).
 
bool IntersectVisit (const CollisionVolumeBSphere &other) const override
 Tests intersection with a bounding sphere.
 
bool IntersectVisit (const CollisionVolumeAABB &other) const override
 Tests intersection with another AABB.
 
bool IntersectVisit (const CollisionVolumeOBB &other) const override
 Tests intersection with an oriented bounding box (OBB).
 
VolumeType GetType () const override
 Gets the type of this collision volume.
 
- Public Member Functions inherited from CollisionVolume
 CollisionVolume (const CollisionVolume &)=delete
 
CollisionVolumeoperator= (const CollisionVolume &)=delete
 
- Public Member Functions inherited from Align16
void * operator new (size_t, void *p) noexcept
 
void * operator new (size_t size) noexcept
 
void operator delete (void *p)
 
void * operator new[] (size_t size) noexcept
 
void operator delete[] (void *p)
 
void * operator new (size_t size, int _BlockUse, char const *_FileName, int _LineNumber) noexcept
 
void operator delete (void *p, int _BlockUse, char const *_FileName, int _LineNumber)
 
void * operator new[] (size_t size, int _BlockUse, char const *_FileName, int _LineNumber) noexcept
 
void operator delete[] (void *p, int _BlockUse, char const *_FileName, int _LineNumber)
 

Private Attributes

Vect minPoint
 The minimum point of the AABB.
 
Vect maxPoint
 The maximum point of the AABB.
 
Model * pColModel
 Pointer to the model associated with this AABB.
 

Friends

class CollidableGroup
 

Detailed Description

Represents an axis-aligned bounding box (AABB) collision volume.

The CollisionVolumeAABB class implements an axis-aligned bounding box for collision detection. An AABB is a rectangular box aligned with the world axes, defined by its minimum and maximum corner points. This class provides methods to compute the AABB from a model and transformation matrix, retrieve its properties, and perform intersection tests with other collision volumes.

Typical usage involves calling ComputeData() to initialize the AABB from a model and world matrix, then using intersection methods for collision queries.

See also
CollisionVolume, CollisionVolumeOBB, CollisionVolumeBSphere, SUNENGINEMathTools

Member Function Documentation

◆ ComputeData() [1/2]

void CollisionVolumeAABB::ComputeData ( const CollisionVolumeBSphere & bsphere)

Computes the AABB from a bounding sphere.

Parameters
bsphereThe bounding sphere to enclose.
Here is the call graph for this function:

◆ ComputeData() [2/2]

void CollisionVolumeAABB::ComputeData ( Model * mod,
const Matrix & mat )
overridevirtual

Computes the collision data for the AABB from a model and transformation matrix.

Parameters
modPointer to the model.
matThe transformation matrix.

This method calculates the AABB's min and max points in world space based on the model's local AABB and the provided transformation matrix.

Implements CollisionVolume.

Here is the caller graph for this function:

◆ ComputeDataFromMinMax()

void CollisionVolumeAABB::ComputeDataFromMinMax ( const Vect & min,
const Vect & max )

Sets the AABB from explicit min and max points.

Parameters
minThe minimum point of the AABB.
maxThe maximum point of the AABB.

◆ DebugView()

void CollisionVolumeAABB::DebugView ( const Vect & col) const
overridevirtual

Visualizes the AABB for debugging purposes.

Parameters
colThe color to use for visualization.

Implements CollisionVolume.

Here is the call graph for this function:

◆ Enclose()

void CollisionVolumeAABB::Enclose ( const CollisionVolumeAABB & other)

Expands this AABB to enclose another AABB.

Parameters
otherThe other AABB to enclose.
Here is the call graph for this function:

◆ GetMax()

const Vect & CollisionVolumeAABB::GetMax ( ) const

Gets the maximum point of the AABB.

Returns
The maximum point of the AABB.
Here is the caller graph for this function:

◆ GetMin()

const Vect & CollisionVolumeAABB::GetMin ( ) const

Gets the minimum point of the AABB.

Returns
The minimum point of the AABB.
Here is the caller graph for this function:

◆ GetModel()

Model * CollisionVolumeAABB::GetModel ( ) const

Gets the model associated with this AABB.

Returns
Pointer to the model.

◆ GetType()

VolumeType CollisionVolumeAABB::GetType ( ) const
inlineoverridevirtual

Gets the type of this collision volume.

Returns
The volume type (VolumeType::AABB).

Reimplemented from CollisionVolume.

◆ IntersectAccept()

bool CollisionVolumeAABB::IntersectAccept ( const CollisionVolume & other) const
overridevirtual

Accepts a collision test with another collision volume (double dispatch).

Parameters
otherThe other collision volume.
Returns
True if the volumes intersect, false otherwise.

Implements CollisionVolume.

◆ IntersectVisit() [1/3]

bool CollisionVolumeAABB::IntersectVisit ( const CollisionVolumeAABB & other) const
overridevirtual

Tests intersection with another AABB.

Parameters
otherThe other AABB volume.
Returns
True if the AABBs intersect, false otherwise.

Implements CollisionVolume.

Here is the call graph for this function:

◆ IntersectVisit() [2/3]

bool CollisionVolumeAABB::IntersectVisit ( const CollisionVolumeBSphere & other) const
overridevirtual

Tests intersection with a bounding sphere.

Parameters
otherThe bounding sphere volume.
Returns
True if the AABB and sphere intersect, false otherwise.

Implements CollisionVolume.

Here is the call graph for this function:

◆ IntersectVisit() [3/3]

bool CollisionVolumeAABB::IntersectVisit ( const CollisionVolumeOBB & other) const
overridevirtual

Tests intersection with an oriented bounding box (OBB).

Parameters
otherThe OBB volume.
Returns
True if the AABB and OBB intersect, false otherwise.

Implements CollisionVolume.

Here is the call graph for this function:

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