Table of Contents

Struct Collidable

Namespace
BepuPhysics.Collidables
Assembly
BepuPhysics.dll

Description of a collidable used by a body living in the broad phase and able to generate collision pairs. Collidables with a ShapeIndex that points to nothing (a default constructed TypedIndex) are not capable of colliding with anything. This can be used for a body which needs no collidable representation.

public struct Collidable
Inherited Members

Fields

BroadPhaseIndex

Index of the collidable in the broad phase. Used to look up the target location for bounding box scatters. Under normal circumstances, this should not be set externally.

public int BroadPhaseIndex

Field Value

int

Continuity

Continuous collision detection settings for this collidable. Includes the collision detection mode to use and tuning variables associated with those modes.

public ContinuousDetection Continuity

Field Value

ContinuousDetection

MaximumSpeculativeMargin

Upper bound on the value of the speculative margin used by the collidable.

public float MaximumSpeculativeMargin

Field Value

float

Remarks

MaxValue tends to be a good default value for discrete or passive mode collidables. The speculative margin will increase in size proportional to velocity magnitude, so having an unlimited maximum won't cost extra if the body isn't moving fast.

Smaller values can be useful for improving performance in chaotic situations where missing a collision is acceptable. When using Continuous, a speculative margin larger than the velocity magnitude will result in the sweep test being skipped, so lowering the maximum margin can help avoid ghost collisions.

MinimumSpeculativeMargin

Lower bound on the value of the speculative margin used by the collidable.

public float MinimumSpeculativeMargin

Field Value

float

Remarks

0 tends to be a good default value. Higher values can be chosen if velocity magnitude is a poor proxy for speculative margins, but these cases are rare. In those cases, try to use the smallest value that still satisfies requirements to avoid creating unnecessary contact constraints.

Shape

Index of the shape used by the body. While this can be changed, any transition from shapeless->shapeful or shapeful->shapeless must be reported to the broad phase. If you need to perform such a transition, consider using SetShape(BodyHandle, TypedIndex) or ApplyDescription(BodyHandle, in BodyDescription); those functions update the relevant state.

public TypedIndex Shape

Field Value

TypedIndex

SpeculativeMargin

Automatically computed size of the margin around the surface of the shape in which contacts can be generated. These contacts will have negative depth and only contribute if the frame's velocities would push the shapes of a pair into overlap.

This is automatically set by bounding box prediction each frame, and is bound by the collidable's MinimumSpeculativeMargin and MaximumSpeculativeMargin values. The effective speculative margin for a collision pair can also be modified from INarrowPhaseCallbacks callbacks.

This should be positive to avoid jittering.

It can also be used as a form of continuous collision detection, but excessively high values combined with fast motion may result in visible 'ghost collision' artifacts. For continuous collision detection with less chance of ghost collisions, use Continuous.

If using Continuous, consider setting MaximumSpeculativeMargin to a smaller value to help filter ghost collisions.

For more information, see the ContinuousCollisionDetection.md documentation.

public float SpeculativeMargin

Field Value

float