Table of Contents

Struct Compound

Namespace
BepuPhysics.Collidables
Assembly
BepuPhysics.dll

Minimalist compound shape containing a list of child shapes. Does not make use of any internal acceleration structure; should be used only with small groups of shapes.

public struct Compound : ICompoundShape, IDisposableShape, IShape, IBoundsQueryableCompound
Implements
Inherited Members

Constructors

Compound(Buffer<CompoundChild>)

Creates a compound shape with no acceleration structure.

public Compound(Buffer<CompoundChild> children)

Parameters

children Buffer<CompoundChild>

Set of children in the compound.

Fields

Children

Buffer of children within this compound.

public Buffer<CompoundChild> Children

Field Value

Buffer<CompoundChild>

Id

Type id of list based compound shapes.

public const int Id = 6

Field Value

int

Properties

ChildCount

Gets the number of children in the compound shape.

public int ChildCount { get; }

Property Value

int

TypeId

Unique type id for this shape type.

public static int TypeId { get; }

Property Value

int

Methods

Add(CompoundChild, BufferPool)

Adds a child to the compound.

public void Add(CompoundChild child, BufferPool pool)

Parameters

child CompoundChild

Child to add to the compound.

pool BufferPool

Pool to use to resize the compound's children buffer if necessary.

AddChildBoundsToBatcher(ref BoundingBoxBatcher, in RigidPose, in BodyVelocity, int)

Submits child shapes to a bounding box batcher for vectorized bounds calculation.

public void AddChildBoundsToBatcher(ref BoundingBoxBatcher batcher, in RigidPose pose, in BodyVelocity velocity, int bodyIndex)

Parameters

batcher BoundingBoxBatcher

Batcher to accumulate children in.

pose RigidPose

Pose of the compound.

velocity BodyVelocity

Velocity of the compound used to expand child bounds.

bodyIndex int

Index of the body in the active body set; used to accumulate child bounds results.

Remarks

This is used internally for bounding box calculation, but it is unlikely to be useful externally.

AddChildBoundsToBatcher(ref Buffer<CompoundChild>, ref BoundingBoxBatcher, in RigidPose, in BodyVelocity, int)

public static void AddChildBoundsToBatcher(ref Buffer<CompoundChild> children, ref BoundingBoxBatcher batcher, in RigidPose pose, in BodyVelocity velocity, int bodyIndex)

Parameters

children Buffer<CompoundChild>
batcher BoundingBoxBatcher
pose RigidPose
velocity BodyVelocity
bodyIndex int

ComputeBounds(Quaternion, Shapes, out Vector3, out Vector3)

Computes the bounding box of a compound shape.

public void ComputeBounds(Quaternion orientation, Shapes shapeBatches, out Vector3 min, out Vector3 max)

Parameters

orientation Quaternion

Orientation of the compound.

shapeBatches Shapes

Shape batches to look up child shape information in.

min Vector3

Minimum of the compound's bounding box.

max Vector3

Maximum of the compound's bounding box.

ComputeChildBounds(in CompoundChild, Quaternion, Shapes, out Vector3, out Vector3)

public static void ComputeChildBounds(in CompoundChild child, Quaternion orientation, Shapes shapeBatches, out Vector3 childMin, out Vector3 childMax)

Parameters

child CompoundChild
orientation Quaternion
shapeBatches Shapes
childMin Vector3
childMax Vector3

ComputeInertia(Span<float>, Shapes)

Computes the inertia of a compound. Does not recenter the child poses.

public BodyInertia ComputeInertia(Span<float> childMasses, Shapes shapes)

Parameters

childMasses Span<float>

Masses of the children.

shapes Shapes

Shapes collection containing the data for the compound child shapes.

Returns

BodyInertia

Inertia of the compound.

ComputeInertia(Span<float>, Shapes, out Vector3)

Computes the inertia of a compound. Recenters the child poses around the calculated center of mass.

public BodyInertia ComputeInertia(Span<float> childMasses, Shapes shapes, out Vector3 centerOfMass)

Parameters

childMasses Span<float>

Masses of the children.

shapes Shapes

Shapes collection containing the data for the compound child shapes.

centerOfMass Vector3

Calculated center of mass of the compound. Subtracted from all the compound child poses.

Returns

BodyInertia

Inertia of the compound.

CreateShapeBatch(BufferPool, int, Shapes)

Creates a shape batch for this type of shape.

public static ShapeBatch CreateShapeBatch(BufferPool pool, int initialCapacity, Shapes shapes)

Parameters

pool BufferPool

Buffer pool used to create the batch.

initialCapacity int

Initial capacity to allocate within the batch.

shapes Shapes

Returns

ShapeBatch

Shape batch for the shape type.

Remarks

This is typically used internally to initialize new shape collections in response to shapes being added. It is not likely to be useful outside of the engine.

Dispose(BufferPool)

Returns all resources used by the shape instance to the given pool.

public void Dispose(BufferPool bufferPool)

Parameters

bufferPool BufferPool

FindLocalOverlaps<TOverlaps>(Vector3, Vector3, Vector3, float, BufferPool, Shapes, void*)

public void FindLocalOverlaps<TOverlaps>(Vector3 min, Vector3 max, Vector3 sweep, float maximumT, BufferPool pool, Shapes shapes, void* overlapsPointer) where TOverlaps : ICollisionTaskSubpairOverlaps

Parameters

min Vector3
max Vector3
sweep Vector3
maximumT float
pool BufferPool
shapes Shapes
overlapsPointer void*

Type Parameters

TOverlaps

FindLocalOverlaps<TOverlaps, TSubpairOverlaps>(ref Buffer<OverlapQueryForPair>, BufferPool, Shapes, ref TOverlaps)

public void FindLocalOverlaps<TOverlaps, TSubpairOverlaps>(ref Buffer<OverlapQueryForPair> pairs, BufferPool pool, Shapes shapes, ref TOverlaps overlaps) where TOverlaps : struct, ICollisionTaskOverlaps<TSubpairOverlaps> where TSubpairOverlaps : struct, ICollisionTaskSubpairOverlaps

Parameters

pairs Buffer<OverlapQueryForPair>
pool BufferPool
shapes Shapes
overlaps TOverlaps

Type Parameters

TOverlaps
TSubpairOverlaps

GetChild(int)

Gets a child from the compound by index.

public ref CompoundChild GetChild(int compoundChildIndex)

Parameters

compoundChildIndex int

Index of the child to look up.

Returns

CompoundChild

Reference to the requested compound child.

GetRotatedChildPose(in RigidPose, Quaternion, out RigidPose)

public static void GetRotatedChildPose(in RigidPose localPose, Quaternion orientation, out RigidPose rotatedChildPose)

Parameters

localPose RigidPose
orientation Quaternion
rotatedChildPose RigidPose

GetRotatedChildPose(in RigidPoseWide, in QuaternionWide, out RigidPoseWide)

public static void GetRotatedChildPose(in RigidPoseWide localPose, in QuaternionWide orientation, out RigidPoseWide rotatedChildPose)

Parameters

localPose RigidPoseWide
orientation QuaternionWide
rotatedChildPose RigidPoseWide

GetRotatedChildPose(in RigidPoseWide, in QuaternionWide, out Vector3Wide, out QuaternionWide)

public static void GetRotatedChildPose(in RigidPoseWide localPose, in QuaternionWide orientation, out Vector3Wide childPosition, out QuaternionWide childOrientation)

Parameters

localPose RigidPoseWide
orientation QuaternionWide
childPosition Vector3Wide
childOrientation QuaternionWide

GetRotatedChildPose(Vector3, Quaternion, Quaternion, out RigidPose)

public static void GetRotatedChildPose(Vector3 localPosition, Quaternion localOrientation, Quaternion orientation, out RigidPose rotatedChildPose)

Parameters

localPosition Vector3
localOrientation Quaternion
orientation Quaternion
rotatedChildPose RigidPose

GetRotatedChildPose(Vector3, Quaternion, Quaternion, out Vector3, out Quaternion)

public static void GetRotatedChildPose(Vector3 localPosition, Quaternion localOrientation, Quaternion parentOrientation, out Vector3 rotatedPosition, out Quaternion rotatedOrientation)

Parameters

localPosition Vector3
localOrientation Quaternion
parentOrientation Quaternion
rotatedPosition Vector3
rotatedOrientation Quaternion

GetWorldPose(in RigidPose, in RigidPose, out RigidPose)

public static void GetWorldPose(in RigidPose localPose, in RigidPose transform, out RigidPose worldPose)

Parameters

localPose RigidPose
transform RigidPose
worldPose RigidPose

RayTest<TRayHitHandler>(in RigidPose, in RayData, ref float, Shapes, ref TRayHitHandler)

Tests a ray against the shape.

public void RayTest<TRayHitHandler>(in RigidPose pose, in RayData ray, ref float maximumT, Shapes shapeBatches, ref TRayHitHandler hitHandler) where TRayHitHandler : struct, IShapeRayHitHandler

Parameters

pose RigidPose

Pose of the shape during the ray test.

ray RayData

Ray to test against the shape.

maximumT float

Maximum distance along the ray, in units of the ray direction's length, that the ray will test.

shapeBatches Shapes

Shape batches to look up child shapes in if necessary.

hitHandler TRayHitHandler

Callbacks called when the ray interacts with a test candidate.

Type Parameters

TRayHitHandler

RayTest<TRayHitHandler>(in RigidPose, ref RaySource, Shapes, ref TRayHitHandler)

Tests multiple rays against the shape.

public void RayTest<TRayHitHandler>(in RigidPose pose, ref RaySource rays, Shapes shapeBatches, ref TRayHitHandler hitHandler) where TRayHitHandler : struct, IShapeRayHitHandler

Parameters

pose RigidPose

Pose of the shape during the ray test.

rays RaySource

Rays to test against the shape.

shapeBatches Shapes

Shape batches to look up child shapes in if necessary.

hitHandler TRayHitHandler

Callbacks called when the ray interacts with a test candidate.

Type Parameters

TRayHitHandler

RemoveAt(int, BufferPool)

Removes a child from the compound by index. The last child is pulled to fill the gap left by the removed child.

public void RemoveAt(int childIndex, BufferPool pool)

Parameters

childIndex int

Index of the child to remove from the compound.

pool BufferPool

Pool to use to resize the compound's children buffer if necessary.

ValidateChildIndex(TypedIndex, Shapes)

Checks if a shape index.

public static bool ValidateChildIndex(TypedIndex shapeIndex, Shapes shapeBatches)

Parameters

shapeIndex TypedIndex

Shape index to analyze.

shapeBatches Shapes

Shape collection into which the index indexes.

Returns

bool

True if the index is valid, false otherwise.

ValidateChildIndices(Span<CompoundChild>, Shapes)

Checks if a set of children shape indices are all valid.

public static bool ValidateChildIndices(Span<CompoundChild> children, Shapes shapeBatches)

Parameters

children Span<CompoundChild>

Children to examine.

shapeBatches Shapes

Shape collection into which the children index.

Returns

bool

True if all child indices are valid, false otherwise.