Interface INarrowPhaseCallbacks
- Namespace
- BepuPhysics.CollisionDetection
- Assembly
- BepuPhysics.dll
Defines handlers for narrow phase events.
public interface INarrowPhaseCallbacks
Methods
AllowContactGeneration(int, CollidableReference, CollidableReference, ref float)
Chooses whether to allow contact generation to proceed for two overlapping collidables.
bool AllowContactGeneration(int workerIndex, CollidableReference a, CollidableReference b, ref float speculativeMargin)
Parameters
workerIndex
intIndex of the worker that identified the overlap.
a
CollidableReferenceReference to the first collidable in the pair.
b
CollidableReferenceReference to the second collidable in the pair.
speculativeMargin
floatReference to the speculative margin used by the pair. The value was already initialized by the narrowphase by examining the speculative margins of the involved collidables, but it can be modified.
Returns
- bool
True if collision detection should proceed, false otherwise.
AllowContactGeneration(int, CollidablePair, int, int)
Chooses whether to allow contact generation to proceed for the children of two overlapping collidables in a compound-including pair.
bool AllowContactGeneration(int workerIndex, CollidablePair pair, int childIndexA, int childIndexB)
Parameters
workerIndex
intIndex of the worker thread processing this pair.
pair
CollidablePairParent pair of the two child collidables.
childIndexA
intIndex of the child of collidable A in the pair. If collidable A is not compound, then this is always 0.
childIndexB
intIndex of the child of collidable B in the pair. If collidable B is not compound, then this is always 0.
Returns
- bool
True if collision detection should proceed, false otherwise.
Remarks
This is called for each sub-overlap in a collidable pair involving compound collidables. If neither collidable in a pair is compound, this will not be called. For compound-including pairs, if the earlier call to AllowContactGeneration returns false for owning pair, this will not be called. Note that it is possible for this function to be called twice for the same subpair if the pair has continuous collision detection enabled; the CCD sweep test that runs before the contact generation test also asks before performing child pair tests.
ConfigureContactManifold(int, CollidablePair, int, int, ref ConvexContactManifold)
Provides a notification that a manifold has been created between the children of two collidables in a compound-including pair. Offers an opportunity to change the manifold's details.
bool ConfigureContactManifold(int workerIndex, CollidablePair pair, int childIndexA, int childIndexB, ref ConvexContactManifold manifold)
Parameters
workerIndex
intIndex of the worker thread that created this manifold.
pair
CollidablePairPair of collidables that the manifold was detected between.
childIndexA
intIndex of the child of collidable A in the pair. If collidable A is not compound, then this is always 0.
childIndexB
intIndex of the child of collidable B in the pair. If collidable B is not compound, then this is always 0.
manifold
ConvexContactManifoldSet of contacts detected between the collidables.
Returns
- bool
True if this manifold should be considered for the parent pair's contact manifold generation, false otherwise.
ConfigureContactManifold<TManifold>(int, CollidablePair, ref TManifold, out PairMaterialProperties)
Provides a notification that a manifold has been created for a pair. Offers an opportunity to change the manifold's details.
bool ConfigureContactManifold<TManifold>(int workerIndex, CollidablePair pair, ref TManifold manifold, out PairMaterialProperties pairMaterial) where TManifold : unmanaged, IContactManifold<TManifold>
Parameters
workerIndex
intIndex of the worker thread that created this manifold.
pair
CollidablePairPair of collidables that the manifold was detected between.
manifold
TManifoldSet of contacts detected between the collidables.
pairMaterial
PairMaterialPropertiesMaterial properties of the manifold.
Returns
- bool
True if a constraint should be created for the manifold, false otherwise.
Type Parameters
TManifold
Dispose()
Releases any resources held by the callbacks. Called by the owning narrow phase when it is being disposed.
void Dispose()
Initialize(Simulation)
Performs any required initialization logic after the Simulation instance has been constructed.
void Initialize(Simulation simulation)
Parameters
simulation
SimulationSimulation that owns these callbacks.