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
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
child
CompoundChildChild to add to the compound.
pool
BufferPoolPool 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
BoundingBoxBatcherBatcher to accumulate children in.
pose
RigidPosePose of the compound.
velocity
BodyVelocityVelocity of the compound used to expand child bounds.
bodyIndex
intIndex 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
BoundingBoxBatcherpose
RigidPosevelocity
BodyVelocitybodyIndex
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
QuaternionOrientation of the compound.
shapeBatches
ShapesShape batches to look up child shape information in.
min
Vector3Minimum of the compound's bounding box.
max
Vector3Maximum 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
CompoundChildorientation
QuaternionshapeBatches
ShapeschildMin
Vector3childMax
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
ShapesShapes 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
ShapesShapes collection containing the data for the compound child shapes.
centerOfMass
Vector3Calculated 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
BufferPoolBuffer pool used to create the batch.
initialCapacity
intInitial 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
Vector3max
Vector3sweep
Vector3maximumT
floatpool
BufferPoolshapes
ShapesoverlapsPointer
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
BufferPoolshapes
Shapesoverlaps
TOverlaps
Type Parameters
TOverlaps
TSubpairOverlaps
GetChild(int)
Gets a child from the compound by index.
public ref CompoundChild GetChild(int compoundChildIndex)
Parameters
compoundChildIndex
intIndex 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
RigidPoseorientation
QuaternionrotatedChildPose
RigidPose
GetRotatedChildPose(in RigidPoseWide, in QuaternionWide, out RigidPoseWide)
public static void GetRotatedChildPose(in RigidPoseWide localPose, in QuaternionWide orientation, out RigidPoseWide rotatedChildPose)
Parameters
localPose
RigidPoseWideorientation
QuaternionWiderotatedChildPose
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
RigidPoseWideorientation
QuaternionWidechildPosition
Vector3WidechildOrientation
QuaternionWide
GetRotatedChildPose(Vector3, Quaternion, Quaternion, out RigidPose)
public static void GetRotatedChildPose(Vector3 localPosition, Quaternion localOrientation, Quaternion orientation, out RigidPose rotatedChildPose)
Parameters
localPosition
Vector3localOrientation
Quaternionorientation
QuaternionrotatedChildPose
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
Vector3localOrientation
QuaternionparentOrientation
QuaternionrotatedPosition
Vector3rotatedOrientation
Quaternion
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
pose
RigidPosePose of the shape during the ray test.
ray
RayDataRay to test against the shape.
maximumT
floatMaximum distance along the ray, in units of the ray direction's length, that the ray will test.
shapeBatches
ShapesShape batches to look up child shapes in if necessary.
hitHandler
TRayHitHandlerCallbacks 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
RigidPosePose of the shape during the ray test.
rays
RaySourceRays to test against the shape.
shapeBatches
ShapesShape batches to look up child shapes in if necessary.
hitHandler
TRayHitHandlerCallbacks 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
intIndex of the child to remove from the compound.
pool
BufferPoolPool 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
TypedIndexShape index to analyze.
shapeBatches
ShapesShape 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
ShapesShape collection into which the children index.
Returns
- bool
True if all child indices are valid, false otherwise.