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

Generic box type for any collision algorithm implementation derived from CollisionAlgorithmImplementation<N>. More...

#include <GREM/physics/collision.hpp>

Public Member Functions

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)
 Perform collision detection using the underlying collision algorithm and determine whether two objects have any touching surfaces or not.
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)
 Perform collision detection using the underlying collision algorithm and generate contact manifolds for touching surfaces.

Static Public Member Functions

template<typename Implementation, typename... Args>
static CollisionAlgorithm create (Args &&... args)
 Create a boxed collision algorithm with a specific implementation.
static CollisionAlgorithm chooseImplementation (ShapeView< N > shapeA, ShapeView< N > shapeB)
 Create a boxed collision algorithm with an implementation that can be used to generate contact points for a given ordered pair of shapes.

Static Public Attributes

static constexpr size_t MAX_CAPACITY = max(sizeof(void*) * 20, size_t{144})
 Maximum capacity for concrete collision algorithm implementations.
static constexpr size_t MAX_ALIGNMENT = max(alignof(void*), size_t{16})
 Maximum alignment for concrete collision algorithm implementations.

Detailed Description

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

Generic box type for any collision algorithm implementation derived from CollisionAlgorithmImplementation<N>.

Member Function Documentation

◆ create()

template<size_t N>
template<typename Implementation, typename... Args>
CollisionAlgorithm grem::physics::CollisionAlgorithm< N >::create ( Args &&... args)
inlinestaticnodiscard

Create a boxed collision algorithm with a specific implementation.

Template Parameters
Implementationconcrete collision algorithm type.
Parameters
argsarguments to forward to the concrete collision algorithm constructor.
Returns
the new boxed collision algorithm.
Exceptions
anyexception thrown by the concrete collision algorithm's constructor.
std::bad_allocon allocation failure.
Warning
CollisionAlgorithmImplementation<N> must be the only base class of the implementation type.

◆ chooseImplementation()

template<size_t N>
CollisionAlgorithm grem::physics::CollisionAlgorithm< N >::chooseImplementation ( ShapeView< N > shapeA,
ShapeView< N > shapeB )
staticnodiscard

Create a boxed collision algorithm with an implementation that can be used to generate contact points for a given ordered pair of shapes.

Parameters
shapeAthe first shape in the pair of shapes to choose a collision algorithm for.
shapeBthe second shape to the pair of shapes to choose a collision algorithm for.
Exceptions
std::bad_allocon allocation failure.

◆ hasCollision()

template<size_t N>
CollisionFilterTestResult grem::physics::CollisionAlgorithm< 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 )
inlinenodiscard

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>
void grem::physics::CollisionAlgorithm< 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 )
inline

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.

Member Data Documentation

◆ MAX_CAPACITY

template<size_t N>
size_t grem::physics::CollisionAlgorithm< N >::MAX_CAPACITY = max(sizeof(void*) * 20, size_t{144})
staticconstexpr

Maximum capacity for concrete collision algorithm implementations.

◆ MAX_ALIGNMENT

template<size_t N>
size_t grem::physics::CollisionAlgorithm< N >::MAX_ALIGNMENT = max(alignof(void*), size_t{16})
staticconstexpr

Maximum alignment for concrete collision algorithm implementations.


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