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

Represents an Oriented Bounding Box (OBB) collision volume. More...

#include <CollisionVolumeOBB.h>

Inheritance diagram for CollisionVolumeOBB:
Inheritance graph

Public Member Functions

 CollisionVolumeOBB (const CollisionVolumeOBB &)=delete
 
CollisionVolumeOBBoperator= (const CollisionVolumeOBB &)=delete
 
void ComputeData (Model *mod, const Matrix &mat) override
 Computes the OBB data from a model and transformation matrix.
 
const Vect & GetCenter () const
 Gets the center of the OBB in world space.
 
const Vect & GetHalfDiagonal () const
 Gets the half-diagonal (half-extents) of the OBB in world space.
 
const Matrix & GetWorldMatrix () const
 Gets the world matrix representing the OBB's orientation and position.
 
const Vect GetMin () const
 Gets the minimum point of the OBB in world space.
 
const Vect GetMax () const
 Gets the maximum point of the OBB in world space.
 
Model * GetModel () const
 Gets the model associated with this OBB.
 
void DebugView (const Vect &col) const override
 Visualizes the OBB 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 an axis-aligned bounding box (AABB).
 
bool IntersectVisit (const CollisionVolumeOBB &other) const override
 Tests intersection with another OBB.
 
void ComputeDataFromMinMax (const Vect &center, const Vect &halfDiagonal)
 Sets the OBB data from a center and half-diagonal in world space.
 
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 center
 Center of the OBB in world space.
 
Vect halfDiagonal
 Half-diagonal (half-extents) of the OBB in world space.
 
Matrix worldMatrix
 World matrix for OBB orientation and position.
 
Model * pColModel
 Pointer to the associated model.
 
Vect localHalfDiagonal
 Half-diagonal in local/model space.
 
Vect localCenter
 Center in local/model space.
 

Detailed Description

Represents an Oriented Bounding Box (OBB) collision volume.

The CollisionVolumeOBB class implements an oriented bounding box for collision detection. An OBB is a rectangular box that can be arbitrarily rotated in 3D space, defined by its center, half-diagonal (half-extents), and orientation (world matrix). This class provides methods to compute the OBB 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 OBB from a model and world matrix, then using intersection methods for collision queries.

See also
CollisionVolume, CollisionVolumeAABB, CollisionVolumeBSphere, SUNENGINEMathTools

Member Function Documentation

◆ ComputeData()

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

Computes the OBB data from a model and transformation matrix.

Parameters
modPointer to the model.
matThe world transformation matrix.

This method calculates the OBB's center, half-diagonal, and orientation in world space based on the model's local AABB and the provided transformation matrix.

Implements CollisionVolume.

Here is the call graph for this function:

◆ ComputeDataFromMinMax()

void CollisionVolumeOBB::ComputeDataFromMinMax ( const Vect & center,
const Vect & halfDiagonal )

Sets the OBB data from a center and half-diagonal in world space.

Parameters
centerThe center of the OBB.
halfDiagonalThe half-diagonal (half-extents) of the OBB.

This method is useful for constructing an OBB from explicit min/max or center/half-diagonal values.

◆ DebugView()

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

Visualizes the OBB for debugging purposes.

Parameters
colThe color to use for visualization.

Implements CollisionVolume.

Here is the call graph for this function:

◆ GetCenter()

const Vect & CollisionVolumeOBB::GetCenter ( ) const

Gets the center of the OBB in world space.

Returns
Reference to the center vector.
Here is the caller graph for this function:

◆ GetHalfDiagonal()

const Vect & CollisionVolumeOBB::GetHalfDiagonal ( ) const

Gets the half-diagonal (half-extents) of the OBB in world space.

Returns
Reference to the half-diagonal vector.
Here is the caller graph for this function:

◆ GetMax()

const Vect CollisionVolumeOBB::GetMax ( ) const

Gets the maximum point of the OBB in world space.

Returns
The maximum corner vector.

◆ GetMin()

const Vect CollisionVolumeOBB::GetMin ( ) const

Gets the minimum point of the OBB in world space.

Returns
The minimum corner vector.

◆ GetModel()

Model * CollisionVolumeOBB::GetModel ( ) const

Gets the model associated with this OBB.

Returns
Pointer to the model.

◆ GetType()

VolumeType CollisionVolumeOBB::GetType ( ) const
inlineoverridevirtual

Gets the type of this collision volume.

Returns
The volume type (VolumeType::OBB).

Reimplemented from CollisionVolume.

◆ GetWorldMatrix()

const Matrix & CollisionVolumeOBB::GetWorldMatrix ( ) const

Gets the world matrix representing the OBB's orientation and position.

Returns
Reference to the world matrix.
Here is the caller graph for this function:

◆ IntersectAccept()

bool CollisionVolumeOBB::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 CollisionVolumeOBB::IntersectVisit ( const CollisionVolumeAABB & other) const
overridevirtual

Tests intersection with an axis-aligned bounding box (AABB).

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

Implements CollisionVolume.

Here is the call graph for this function:

◆ IntersectVisit() [2/3]

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

Tests intersection with a bounding sphere.

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

Implements CollisionVolume.

Here is the call graph for this function:

◆ IntersectVisit() [3/3]

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

Tests intersection with another OBB.

Parameters
otherThe other OBB volume.
Returns
True if the OBBs intersect, false otherwise.

Implements CollisionVolume.

Here is the call graph for this function:

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