Oxygen Engine
Modern C++ 3D Engine using OpenGL
Loading...
Searching...
No Matches
oe::scene::AABB Class Reference

Axis-aligned bounding box. More...

#include <OxygenEngine/scene/aabb.h>

Public Member Functions

 AABB ()=default
 Create an empty box centered at origin.
 
 AABB (const glm::vec3 &extents)
 Create a box centered at origin.
 
 AABB (const glm::vec3 &mini, const glm::vec3 &maxi)
 Create a box by providing bounds.
 
glm::vec3 getCenter () const noexcept
 Get coordinates of the box center.
 
void setBounds (const glm::vec3 &mini, const glm::vec3 &maxi) noexcept
 Update box bounds.
 
void extendToPoint (const glm::vec3 &point) noexcept
 Update box size to contain the point.
 
AABB transform (const glm::mat4 &model) const noexcept
 Returns a new AABB transformed according to a model matrix.
 
void extendToAABB (const oe::scene::AABB &aabb) noexcept
 Increase box size to contain another AABB.
 
AABBoperator+= (const AABB &aabb) noexcept
 Increase box size to contain another AABB.
 
void scale (const glm::vec3 &scale) noexcept
 Scale the bounding box.
 
glm::vec3 getExtents () const noexcept
 Get the box distance between min and max.
 
float getVolume () const noexcept
 Get the box volume.
 
bool isEmpty () const noexcept
 Check if the box is empty.
 
bool hasCollision (const AABB &box) const noexcept
 Check an box collision with this box.
 
bool hasCollision (const glm::vec3 &center, const float &radius) const noexcept
 Check a sphere collision with this box.
 
bool contains (const glm::vec3 &point) const noexcept
 Check if a point is in this box.
 
bool contains (const AABB &box) const noexcept
 Check if another AABB is completely inside this box.
 

Public Attributes

glm::vec3 min = glm::vec3(0.0)
 Minimum point of bounds.
 
glm::vec3 max = glm::vec3(0.0)
 Maximum point of bounds.
 

Detailed Description

Axis-aligned bounding box.

Constructor & Destructor Documentation

◆ AABB() [1/2]

oe::scene::AABB::AABB ( const glm::vec3 &  extents)
inlineexplicit

Create a box centered at origin.

Parameters
extentsDimensions of the bounding box

◆ AABB() [2/2]

oe::scene::AABB::AABB ( const glm::vec3 &  mini,
const glm::vec3 &  maxi 
)
inline

Create a box by providing bounds.

Parameters
minMinimum bounds
maxMaximum bounds

Member Function Documentation

◆ contains() [1/2]

bool oe::scene::AABB::contains ( const AABB box) const
inlinenoexcept

Check if another AABB is completely inside this box.

Parameters
boxAABB
Returns
True if this box entirely contains the provided box

◆ contains() [2/2]

bool oe::scene::AABB::contains ( const glm::vec3 &  point) const
inlinenoexcept

Check if a point is in this box.

Parameters
pointPoint coordinates
Returns
True if this box contain the point at specified coordinates

◆ extendToAABB()

void oe::scene::AABB::extendToAABB ( const oe::scene::AABB aabb)
inlinenoexcept

Increase box size to contain another AABB.

Parameters
aabbBox to include in this one

◆ extendToPoint()

void oe::scene::AABB::extendToPoint ( const glm::vec3 &  point)
inlinenoexcept

Update box size to contain the point.

Parameters
pointPoint coordinates

◆ getCenter()

glm::vec3 oe::scene::AABB::getCenter ( ) const
inlinenoexcept

Get coordinates of the box center.

Returns
Origin of the bounding box

◆ getExtents()

glm::vec3 oe::scene::AABB::getExtents ( ) const
inlinenoexcept

Get the box distance between min and max.

Returns
Distance between each edges

◆ getVolume()

float oe::scene::AABB::getVolume ( ) const
inlinenoexcept

Get the box volume.

Returns
volume in cubical units

◆ hasCollision() [1/2]

bool oe::scene::AABB::hasCollision ( const AABB box) const
inlinenoexcept

Check an box collision with this box.

Parameters
boxRemote AABB to check collision
Returns
True if this box collides with the provided box

◆ hasCollision() [2/2]

bool oe::scene::AABB::hasCollision ( const glm::vec3 &  center,
const float &  radius 
) const
inlinenoexcept

Check a sphere collision with this box.

Parameters
centerSphere center
radiusSphere radius
Returns
True if this box collides with the sphere

◆ isEmpty()

bool oe::scene::AABB::isEmpty ( ) const
inlinenoexcept

Check if the box is empty.

Returns
True if the box has no volume

◆ operator+=()

AABB & oe::scene::AABB::operator+= ( const AABB aabb)
inlinenoexcept

Increase box size to contain another AABB.

shorthand of extendToAABB()

◆ scale()

void oe::scene::AABB::scale ( const glm::vec3 &  scale)
inlinenoexcept

Scale the bounding box.

Parameters
scaleScaling factor

◆ setBounds()

void oe::scene::AABB::setBounds ( const glm::vec3 &  mini,
const glm::vec3 &  maxi 
)
inlinenoexcept

Update box bounds.

Parameters
miniMinimum bounds
maxiMaximum bounds

◆ transform()

AABB oe::scene::AABB::transform ( const glm::mat4 &  model) const
inlinenoexcept

Returns a new AABB transformed according to a model matrix.

Note
This one is kept as-is
Parameters
modelModel matrix
Returns
New box transformed

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