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
childrenBuffer<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
Properties
ChildCount
Gets the number of children in the compound shape.
public int ChildCount { get; }
Property Value
TypeId
Unique type id for this shape type.
public static int TypeId { get; }
Property Value
Methods
Add(CompoundChild, BufferPool)
Adds a child to the compound.
public void Add(CompoundChild child, BufferPool pool)
Parameters
childCompoundChildChild to add to the compound.
poolBufferPoolPool 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
batcherBoundingBoxBatcherBatcher to accumulate children in.
poseRigidPosePose of the compound.
velocityBodyVelocityVelocity of the compound used to expand child bounds.
bodyIndexintIndex 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
childrenBuffer<CompoundChild>batcherBoundingBoxBatcherposeRigidPosevelocityBodyVelocitybodyIndexint
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
orientationQuaternionOrientation of the compound.
shapeBatchesShapesShape batches to look up child shape information in.
minVector3Minimum of the compound's bounding box.
maxVector3Maximum 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
childCompoundChildorientationQuaternionshapeBatchesShapeschildMinVector3childMaxVector3
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
childMassesSpan<float>Masses of the children.
shapesShapesShapes 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
childMassesSpan<float>Masses of the children.
shapesShapesShapes collection containing the data for the compound child shapes.
centerOfMassVector3Calculated 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
poolBufferPoolBuffer pool used to create the batch.
initialCapacityintInitial capacity to allocate within the batch.
shapesShapes
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
bufferPoolBufferPool
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
minVector3maxVector3sweepVector3maximumTfloatpoolBufferPoolshapesShapesoverlapsPointervoid*
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
pairsBuffer<OverlapQueryForPair>poolBufferPoolshapesShapesoverlapsTOverlaps
Type Parameters
TOverlapsTSubpairOverlaps
GetChild(int)
Gets a child from the compound by index.
public ref CompoundChild GetChild(int compoundChildIndex)
Parameters
compoundChildIndexintIndex 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
localPoseRigidPoseorientationQuaternionrotatedChildPoseRigidPose
GetRotatedChildPose(in RigidPoseWide, in QuaternionWide, out RigidPoseWide)
public static void GetRotatedChildPose(in RigidPoseWide localPose, in QuaternionWide orientation, out RigidPoseWide rotatedChildPose)
Parameters
localPoseRigidPoseWideorientationQuaternionWiderotatedChildPoseRigidPoseWide
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
localPoseRigidPoseWideorientationQuaternionWidechildPositionVector3WidechildOrientationQuaternionWide
GetRotatedChildPose(Vector3, Quaternion, Quaternion, out RigidPose)
public static void GetRotatedChildPose(Vector3 localPosition, Quaternion localOrientation, Quaternion orientation, out RigidPose rotatedChildPose)
Parameters
localPositionVector3localOrientationQuaternionorientationQuaternionrotatedChildPoseRigidPose
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
localPositionVector3localOrientationQuaternionparentOrientationQuaternionrotatedPositionVector3rotatedOrientationQuaternion
GetWorldPose(in RigidPose, in RigidPose, out RigidPose)
public static void GetWorldPose(in RigidPose localPose, in RigidPose transform, out RigidPose worldPose)
Parameters
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
poseRigidPosePose of the shape during the ray test.
rayRayDataRay to test against the shape.
maximumTfloatMaximum distance along the ray, in units of the ray direction's length, that the ray will test.
shapeBatchesShapesShape batches to look up child shapes in if necessary.
hitHandlerTRayHitHandlerCallbacks 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
poseRigidPosePose of the shape during the ray test.
raysRaySourceRays to test against the shape.
shapeBatchesShapesShape batches to look up child shapes in if necessary.
hitHandlerTRayHitHandlerCallbacks 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
childIndexintIndex of the child to remove from the compound.
poolBufferPoolPool 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
shapeIndexTypedIndexShape index to analyze.
shapeBatchesShapesShape 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
childrenSpan<CompoundChild>Children to examine.
shapeBatchesShapesShape collection into which the children index.
Returns
- bool
True if all child indices are valid, false otherwise.