Table of Contents

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 int

Index of the worker that identified the overlap.

a CollidableReference

Reference to the first collidable in the pair.

b CollidableReference

Reference to the second collidable in the pair.

speculativeMargin float

Reference 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 int

Index of the worker thread processing this pair.

pair CollidablePair

Parent pair of the two child collidables.

childIndexA int

Index of the child of collidable A in the pair. If collidable A is not compound, then this is always 0.

childIndexB int

Index 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 int

Index of the worker thread that created this manifold.

pair CollidablePair

Pair of collidables that the manifold was detected between.

childIndexA int

Index of the child of collidable A in the pair. If collidable A is not compound, then this is always 0.

childIndexB int

Index of the child of collidable B in the pair. If collidable B is not compound, then this is always 0.

manifold ConvexContactManifold

Set 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 int

Index of the worker thread that created this manifold.

pair CollidablePair

Pair of collidables that the manifold was detected between.

manifold TManifold

Set of contacts detected between the collidables.

pairMaterial PairMaterialProperties

Material 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 Simulation

Simulation that owns these callbacks.