You.i Engine
CYIAABB Class Reference

Detailed Description

This class represents an Axis-Aligned Bounding Box.

All operations provided for this box will maintain the axis-aligned property.

The validity of the axis-aligned bounding box can be verified with IsValid.

#include <scenetree/YiAABB.h>

Public Member Functions

 CYIAABB ()
 
 CYIAABB (const glm::vec3 &rMinimumExtent, const glm::vec3 &rMaximumExtent)
 
void Enlarge (const CYIAABB &box)
 
glm::vec3 GetCentroid () const
 
glm::vec3 GetHalfDimensions () const
 
float GetWidth () const
 
float GetHeight () const
 
float GetDepth () const
 
const glm::vec3 & GetTopLeft () const
 
const glm::vec3 & GetBottomRight () const
 
bool Intersects (const CYIRay &rRay, glm::vec3 *pCollision=nullptr) const
 
bool Intersects (const CYIAABB &rOther) const
 
void SetCorners (const glm::vec3 &rMinimumExtent, const glm::vec3 &rMaximumExtent)
 
CYIAABB Intersection (const CYIAABB &rOther) const
 
bool IsValid () const
 
void Transform (const glm::mat4 &transform)
 
bool operator== (const CYIAABB &other) const
 
bool operator!= (const CYIAABB &other) const
 

Constructor & Destructor Documentation

◆ CYIAABB() [1/2]

CYIAABB::CYIAABB ( )

Constructs a zero-sized bounding box. Such a bounding box is, by definition, invalid until it is enlarged using CYIAABB::Enlarge() or using CYIAABB::SetCorners().

◆ CYIAABB() [2/2]

CYIAABB::CYIAABB ( const glm::vec3 &  rMinimumExtent,
const glm::vec3 &  rMaximumExtent 
)

Constructs an AABB using the minimum extent rMinimumExtent (representing the top-left corner) and the maximum extent rMaximumExtent (representing the bottom-right corner).

The bounding box will axis align if the provided vectors are not valid.

Member Function Documentation

◆ Enlarge()

void CYIAABB::Enlarge ( const CYIAABB box)

Enlarges the bounding box to encapsulate the provided box.

If box is already within the bounds of this bounding box, there will be no effect.

◆ GetBottomRight()

const glm::vec3& CYIAABB::GetBottomRight ( ) const

Returns a point (x,y,z) representing the maximum extents of the bounding box on all three axes.

Any other point within the bounding box is guaranteed to be less than or equal to this point in one or more of the three dimensions.

◆ GetCentroid()

glm::vec3 CYIAABB::GetCentroid ( ) const

Returns a point (x,y,z) representing the center of the bounding box.

Warning
This is not the same as the dimensions divided by two. The point will be offset by the top left of the bounding box.
See also
GetHalfDimensions()

◆ GetDepth()

float CYIAABB::GetDepth ( ) const

◆ GetHalfDimensions()

glm::vec3 CYIAABB::GetHalfDimensions ( ) const

Returns a vector (x,y,z) representing half the width, height, and depth respectively.

◆ GetHeight()

float CYIAABB::GetHeight ( ) const

◆ GetTopLeft()

const glm::vec3& CYIAABB::GetTopLeft ( ) const

Returns a point (x,y,z) representing the minimum extents of the bounding box on all three axes.

Any other point within the bounding box is guaranteed to be greater than or equal to this point in one or more of the three dimensions.

◆ GetWidth()

float CYIAABB::GetWidth ( ) const

◆ Intersection()

CYIAABB CYIAABB::Intersection ( const CYIAABB rOther) const

Returns the intersection of rOther with this bounding box.

◆ Intersects() [1/2]

bool CYIAABB::Intersects ( const CYIRay rRay,
glm::vec3 *  pCollision = nullptr 
) const

Given a rRay and a pointer to a vector pCollision, populates pCollision with the point of intersection between the ray and this bounding box.

The return value represents whether the collision point is within the bounding box.

Warning
The bounding box will be expanded on X and Y to check for a collision point outside of the box dimensions, this applies in 2D only.
The return value of this function is undefined if rRay is invalid (e.g. if it was created from a zero-length vector).

◆ Intersects() [2/2]

bool CYIAABB::Intersects ( const CYIAABB rOther) const

Returns true if the AABB rOther intersects with this one, false otherwise.

Note
Two AABB's 'touching' at a side or corner are considered to be intersecting.

◆ IsValid()

bool CYIAABB::IsValid ( ) const

A bounding box is valid if all dimensions are greater than 0.

◆ operator!=()

bool CYIAABB::operator!= ( const CYIAABB other) const

◆ operator==()

bool CYIAABB::operator== ( const CYIAABB other) const

◆ SetCorners()

void CYIAABB::SetCorners ( const glm::vec3 &  rMinimumExtent,
const glm::vec3 &  rMaximumExtent 
)

Sets corners of the object/box, here MinimumExtent refers to TopLeft corner and MaximumExtent refers to BottomRight corner.

The bounding box will axis align if the provided vectors are not valid.

◆ Transform()

void CYIAABB::Transform ( const glm::mat4 &  transform)

Transforms the bounding box by the given 3D transformation matrix, and axis aligns the result.


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