GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::physics::CollisionAlgorithmImplementation< N > Class Template Referenceabstract

Base interface for a stateful collision algorithm that generates contact points between two potentially colliding objects of specific shape types. More...

#include <GREM/physics/collision.hpp>

Public Member Functions

virtual CollisionFilterTestResult hasCollision (ArenaResource *temporaryMemoryResource, Length1D minPenetrationDepth, ColliderView< N > colliderA, const Transformation< N > &transformationA, ColliderView< N > colliderB, const Transformation< N > &transformationB, const CollisionAlgorithmOptions< N > &options, CollisionFilterTest filterTest)=0
 Perform collision detection using the underlying collision algorithm and determine whether two objects have any touching surfaces or not.
virtual void detectCollisions (ArenaResource *temporaryMemoryResource, ColliderView< N > colliderA, const Transformation< N > &transformationA, ColliderView< N > colliderB, const Transformation< N > &transformationB, const CollisionAlgorithmOptions< N > &options, CollisionFilterTest filterTest, FunctionView< void(const CollisionAlgorithmResult< N > &collision)> callback)=0
 Perform collision detection using the underlying collision algorithm and generate contact manifolds for touching surfaces.

Protected Member Functions

constexpr CollisionAlgorithmImplementation () noexcept=default
 Construct a new collision algorithm.

Detailed Description

template<size_t N>
class grem::physics::CollisionAlgorithmImplementation< N >

Base interface for a stateful collision algorithm that generates contact points between two potentially colliding objects of specific shape types.

Template Parameters
Nnumber of dimensions of the world space (must be 2 or 3).

Constructor & Destructor Documentation

◆ CollisionAlgorithmImplementation()

template<size_t N>
grem::physics::CollisionAlgorithmImplementation< N >::CollisionAlgorithmImplementation ( )
constexprprotecteddefaultnoexcept

Construct a new collision algorithm.

Member Function Documentation

◆ hasCollision()

template<size_t N>
virtual CollisionFilterTestResult grem::physics::CollisionAlgorithmImplementation< N >::hasCollision ( ArenaResource * temporaryMemoryResource,
Length1D minPenetrationDepth,
ColliderView< N > colliderA,
const Transformation< N > & transformationA,
ColliderView< N > colliderB,
const Transformation< N > & transformationB,
const CollisionAlgorithmOptions< N > & options,
CollisionFilterTest filterTest )
nodiscardpure virtual

Perform collision detection using the underlying collision algorithm and determine whether two objects have any touching surfaces or not.

Parameters
temporaryMemoryResourcenon-null non-owning pointer to a memory resource to use for temporary memory allocations, which will all be deallocated by the time the function returns.
minPenetrationDepthminimum penetration depth for a contact to be considered to be colliding.
colliderAcollider of the first object. Must have the same shape type as the first of the two shapes that this collision algorithm was created to handle.
transformationAworld-space transformation of the first object.
colliderBcollider of the second object. Must have the same shape type as the second of the two shapes that this collision algorithm was created to handle.
transformationBworld-space transformation of the second object.
optionscollision algorithm options, see CollisionAlgorithmOptions. Should usually be simulation.resources.getResource<SimulationOptions<N>>().collisionAlgorithmOptions.
filterTesttest that potential colliders must pass in order to be considered for collision.
Returns
the result of the test, or an empty test result that converts to false if the objects weren't colliding.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ detectCollisions()

template<size_t N>
virtual void grem::physics::CollisionAlgorithmImplementation< N >::detectCollisions ( ArenaResource * temporaryMemoryResource,
ColliderView< N > colliderA,
const Transformation< N > & transformationA,
ColliderView< N > colliderB,
const Transformation< N > & transformationB,
const CollisionAlgorithmOptions< N > & options,
CollisionFilterTest filterTest,
FunctionView< void(const CollisionAlgorithmResult< N > &collision)> callback )
pure virtual

Perform collision detection using the underlying collision algorithm and generate contact manifolds for touching surfaces.

Parameters
temporaryMemoryResourcenon-null non-owning pointer to a memory resource to use for temporary memory allocations, which will all be deallocated by the time the function returns.
colliderAcollider of the first object. Must have the same shape type as the first of the two shapes that this collision algorithm was created to handle.
transformationAworld-space transformation of the first object.
colliderBcollider of the second object. Must have the same shape type as the second of the two shapes that this collision algorithm was created to handle.
transformationBworld-space transformation of the second object.
optionscollision algorithm options, see CollisionAlgorithmOptions. Should usually be simulation.resources.getResource<SimulationOptions<N>>().collisionAlgorithmOptions.
filterTesttest that potential colliders must pass in order to be considered for collision.
callbackfunction to pass the results to.
Exceptions
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
anyexception thrown by the callback function.

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