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

Abstract base class for collision volumes in the physics engine. More...

#include <ICollider.h>

Inheritance diagram for Physics::Bounding::ICollider:
[legend]

Public Member Functions

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

Detailed Description

Abstract base class for collision volumes in the physics engine.

Defines the interface for 3D collision primitives such as axis-aligned bounding boxes (AABB) and oriented bounding boxes (OBB). Colliders support both discrete intersection tests and continuous queries for closest points.

Note
Colliders are defined in local space. Transform them to world space using getTransformed() before collision checks.
Ownership Model
ICollider instances are typically owned by PhysicsBody objects. When transformed copies are created via getTransformed(), ownership is transferred to the caller.
Derived Classes
  • AABB: Axis-aligned bounding box (fast, simple)
  • BoxCollider: Oriented bounding box (arbitrary rotation)
  • SphereCollider: (planned, not yet implemented)
See also
AABB, BoxCollider, PhysicsBody

Definition at line 64 of file ICollider.h.

Constructor & Destructor Documentation

◆ ~ICollider()

virtual Physics::Bounding::ICollider::~ICollider ( )
virtualdefault

Virtual destructor for proper cleanup of derived classes.

Member Function Documentation

◆ closestPoint()

virtual ContactInfo Physics::Bounding::ICollider::closestPoint ( const glm::vec3 &  p) const
pure virtual

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

Implemented in Physics::Bounding::AABB, and Physics::Bounding::BoxCollider.

◆ contains()

virtual bool Physics::Bounding::ICollider::contains ( const glm::vec3 &  p) const
pure virtual

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

Implemented in Physics::Bounding::AABB, and Physics::Bounding::BoxCollider.

◆ getAABBMax()

virtual glm::vec3 Physics::Bounding::ICollider::getAABBMax ( ) const
inlinevirtual

Implemented in Physics::Bounding::AABB, and Physics::Bounding::BoxCollider.

Definition at line 145 of file ICollider.h.

◆ getAABBMin()

virtual glm::vec3 Physics::Bounding::ICollider::getAABBMin ( ) const
inlinevirtual

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.

Implemented in Physics::Bounding::AABB, and Physics::Bounding::BoxCollider.

Definition at line 144 of file ICollider.h.

◆ getTransformed()

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

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)

Implemented in Physics::Bounding::AABB, and Physics::Bounding::BoxCollider.

Here is the caller graph for this function:

◆ intersectRay()

virtual std::optional< float > Physics::Bounding::ICollider::intersectRay ( const Math::Ray ray) const
pure virtual

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

Implemented in Physics::Bounding::AABB, and Physics::Bounding::BoxCollider.


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