Physics Simulation & Visualization Tool 0.1
A C++ physics simulation engine with real-time 3D visualization
Loading...
Searching...
No Matches
Physics::Bounding::AABB Class Reference

#include <AABB.h>

Inheritance diagram for Physics::Bounding::AABB:
[legend]
Collaboration diagram for Physics::Bounding::AABB:
[legend]

Public Member Functions

 AABB ()=default
 
 AABB (const glm::vec3 &center, const glm::vec3 &halfExtents)
 
std::unique_ptr< ICollidergetTransformed (const glm::mat4 &modelMatrix) const override
 Creates a transformed copy of this collider in world space.
 
bool intersectsAABB (const AABB &other) const
 
std::optional< float > intersectRay (const Math::Ray &ray) const override
 Tests ray-collider intersection.
 
bool contains (const glm::vec3 &p) const override
 Tests if a point is inside the collider volume.
 
ContactInfo closestPoint (const glm::vec3 &p) const override
 Finds the closest point on the collider surface to a given point.
 
void expand (const glm::vec3 &point)
 
void expand (const AABB &other)
 
glm::vec3 getAABBMin () const override
 Gets the minimum, maximum corner of the axis-aligned bounding box (AABB) that contains this collider.
 
glm::vec3 getAABBMax () const override
 
glm::vec3 getCenter () const
 
- Public Member Functions inherited from Physics::Bounding::ICollider
virtual ~ICollider ()=default
 Virtual destructor for proper cleanup of derived classes.
 

Detailed Description

Definition at line 6 of file AABB.h.

Constructor & Destructor Documentation

◆ AABB() [1/2]

Physics::Bounding::AABB::AABB ( )
default

◆ AABB() [2/2]

Physics::Bounding::AABB::AABB ( const glm::vec3 &  center,
const glm::vec3 &  halfExtents 
)

Definition at line 8 of file AABB.cpp.

Member Function Documentation

◆ closestPoint()

Physics::Bounding::ContactInfo Physics::Bounding::AABB::closestPoint ( const glm::vec3 &  p) const
overridevirtual

Finds the closest point on the collider surface to a given point.

Parameters
pQuery point in the same space as the collider
Returns
ContactInfo containing closest point, normal, and penetration depth
Note
If p is inside the collider, penetration will be positive
The normal always points away from the collider surface
Use Cases
  • Collision resolution (finding separation vector)
  • Distance queries
  • Computing contact manifolds
See also
ContactInfo

Implements Physics::Bounding::ICollider.

Definition at line 56 of file AABB.cpp.

◆ contains()

bool Physics::Bounding::AABB::contains ( const glm::vec3 &  p) const
overridevirtual

Tests if a point is inside the collider volume.

Parameters
pPoint to test, in the same coordinate space as this collider
Returns
true if point is inside or on the surface, false otherwise
Note
For box colliders, "inside" includes the surface (closed volume)
This test is typically performed in world space after transformation

Implements Physics::Bounding::ICollider.

Definition at line 50 of file AABB.cpp.

◆ expand() [1/2]

void Physics::Bounding::AABB::expand ( const AABB other)

Definition at line 68 of file AABB.cpp.

Here is the call graph for this function:

◆ expand() [2/2]

void Physics::Bounding::AABB::expand ( const glm::vec3 &  point)

Definition at line 61 of file AABB.cpp.

◆ getAABBMax()

glm::vec3 Physics::Bounding::AABB::getAABBMax ( ) const
inlineoverridevirtual

Implements Physics::Bounding::ICollider.

Definition at line 22 of file AABB.h.

Here is the caller graph for this function:

◆ getAABBMin()

glm::vec3 Physics::Bounding::AABB::getAABBMin ( ) const
inlineoverridevirtual

Gets the minimum, maximum corner of the axis-aligned bounding box (AABB) that contains this collider.

Returns
Minimum or Maximum corner of AABB in local space
Note
This is used for broad-phase collision detection and spatial partitioning
For simple colliders like AABB, this is just the min,max corner. For others, it may require computation.

Implements Physics::Bounding::ICollider.

Definition at line 21 of file AABB.h.

Here is the caller graph for this function:

◆ getCenter()

glm::vec3 Physics::Bounding::AABB::getCenter ( ) const
inline

Definition at line 23 of file AABB.h.

◆ getTransformed()

std::unique_ptr< Physics::Bounding::ICollider > Physics::Bounding::AABB::getTransformed ( const glm::mat4 &  modelMatrix) const
overridevirtual

Creates a transformed copy of this collider in world space.

Applies a 4x4 transformation matrix to create a new collider instance representing this shape in world coordinates. This is used to transform local-space colliders to world space for collision testing.

Parameters
modelMatrixTransformation matrix (typically from SceneObject) Encodes translation, rotation, and scale
Returns
Unique pointer to transformed collider (ownership transferred)
Note
The transformation extracts:
  • Translation: modelMatrix[3].xyz
  • Rotation: Extracted via glm::decompose
  • Scale: Applied to half-extents/radius
Caller receives ownership via std::unique_ptr
Returns nullptr only if transformation fails (rare)

Implements Physics::Bounding::ICollider.

Definition at line 11 of file AABB.cpp.

Here is the caller graph for this function:

◆ intersectRay()

std::optional< float > Physics::Bounding::AABB::intersectRay ( const Math::Ray ray) const
overridevirtual

Tests ray-collider intersection.

Parameters
rayThe ray to test against this collider
Returns
Distance along ray if intersection occurs, std::nullopt otherwise
Note
Negative distances may be rejected depending on implementation
See also
Ray

Implements Physics::Bounding::ICollider.

Definition at line 34 of file AABB.cpp.

◆ intersectsAABB()

bool Physics::Bounding::AABB::intersectsAABB ( const AABB other) const

Definition at line 27 of file AABB.cpp.

Here is the caller graph for this function:

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