Class Statics
- Namespace
- BepuPhysics
- Assembly
- BepuPhysics.dll
Collection of allocated statics.
public class Statics
- Inheritance
-
Statics
- Inherited Members
Constructors
Statics(BufferPool, Shapes, Bodies, BroadPhase, int)
public Statics(BufferPool pool, Shapes shapes, Bodies bodies, BroadPhase broadPhase, int initialCapacity = 4096)
Parameters
pool
BufferPoolshapes
Shapesbodies
BodiesbroadPhase
BroadPhaseinitialCapacity
int
Fields
Count
public int Count
Field Value
HandlePool
public IdPool HandlePool
Field Value
- IdPool
HandleToIndex
Remaps a static handle integer value to the actual array index of the static.
public Buffer<int> HandleToIndex
Field Value
- Buffer<int>
IndexToHandle
Remaps a static index to its handle.
public Buffer<StaticHandle> IndexToHandle
Field Value
- Buffer<StaticHandle>
StaticsBuffer
The set of collidables owned by each static. Speculative margins, continuity settings, and shape indices can be changed directly. Shape indices cannot transition between pointing at a shape and pointing at nothing or vice versa without notifying the broad phase of the collidable addition or removal. Consider using SetShape(StaticHandle, TypedIndex) or ApplyDescription(StaticHandle, in StaticDescription) to handle the bookkeeping changes automatically if changing the shape.
public Buffer<Static> StaticsBuffer
Field Value
- Buffer<Static>
pool
protected BufferPool pool
Field Value
- BufferPool
Properties
this[StaticHandle]
Gets a reference to the memory backing a static collidable. The StaticReference type is a helper that exposes common operations for statics.
public StaticReference this[StaticHandle handle] { get; }
Parameters
handle
StaticHandleHandle of the static to retrieve a reference for.
Property Value
- StaticReference
Reference to the memory backing a static collidable.
Remarks
Equivalent to GetStaticReference(StaticHandle).
this[int]
Gets a reference to the raw memory backing a static collidable.
public ref Static this[int index] { get; }
Parameters
index
intIndex of the static to retrieve a memory reference for.
Property Value
- Static
Direct reference to the memory backing a static collidable.
Methods
Add(in StaticDescription)
Adds a new static body to the simulation. All sleeping dynamic bodies whose bounding boxes overlap the new static are forced active.
public StaticHandle Add(in StaticDescription description)
Parameters
description
StaticDescriptionDescription of the static to add.
Returns
- StaticHandle
Handle of the new static.
Add<TAwakeningFilter>(in StaticDescription, ref TAwakeningFilter)
Adds a new static body to the simulation. All sleeping bodies whose bounding boxes overlap the new static and pass the given filter are forced active.
public StaticHandle Add<TAwakeningFilter>(in StaticDescription description, ref TAwakeningFilter filter) where TAwakeningFilter : struct, IStaticChangeAwakeningFilter
Parameters
description
StaticDescriptionDescription of the static to add.
filter
TAwakeningFilterFilter to apply to sleeping bodies near the new static to see if they should be awoken.
Returns
- StaticHandle
Handle of the new static.
Type Parameters
TAwakeningFilter
Type of the filter to apply to sleeping bodies.
ApplyDescription(StaticHandle, in StaticDescription)
Applies a new description to an existing static object. All sleeping bodies with bounding boxes overlapping the old or new static collidable and pass the given filter are forced active. Updates the bounds of the static in the broad phase.
public void ApplyDescription(StaticHandle handle, in StaticDescription description)
Parameters
handle
StaticHandleHandle of the static to apply the description to.
description
StaticDescriptionDescription to apply to the static.
ApplyDescription<TAwakeningFilter>(StaticHandle, in StaticDescription, ref TAwakeningFilter)
Applies a new description to an existing static object. All sleeping bodies with bounding boxes overlapping the old or new static collidable and pass the given filter are forced active. Updates the bounds of the static in the broad phase.
public void ApplyDescription<TAwakeningFilter>(StaticHandle handle, in StaticDescription description, ref TAwakeningFilter filter) where TAwakeningFilter : struct, IStaticChangeAwakeningFilter
Parameters
handle
StaticHandleHandle of the static to apply the description to.
description
StaticDescriptionDescription to apply to the static.
filter
TAwakeningFilterFilter to apply to sleeping bodies near the static to see if they should be awoken.
Type Parameters
TAwakeningFilter
Type of the filter to apply to sleeping bodies.
Clear()
Clears all bodies from the set without returning any memory to the pool.
public void Clear()
Dispose()
Returns all static resources to the pool used to create them.
public void Dispose()
Remarks
The object can be reused if it is reinitialized by using EnsureCapacity or Resize.
EnsureCapacity(int)
Increases the size of buffers if needed to hold the target capacity.
public void EnsureCapacity(int capacity)
Parameters
capacity
intTarget data capacity.
GetDescription(StaticHandle)
Gets the current description of the static referred to by a given handle.
public StaticDescription GetDescription(StaticHandle handle)
Parameters
handle
StaticHandleHandle of the static to look up the description of.
Returns
- StaticDescription
Gathered description of the handle-referenced static.
GetDescription(StaticHandle, out StaticDescription)
Gets the current description of the static referred to by a given handle.
public void GetDescription(StaticHandle handle, out StaticDescription description)
Parameters
handle
StaticHandleHandle of the static to look up the description of.
description
StaticDescriptionGathered description of the handle-referenced static.
GetDirectReference(StaticHandle)
Gets a direct reference to the memory backing a static.
public ref Static GetDirectReference(StaticHandle handle)
Parameters
handle
StaticHandleHandle of the static to get a reference of.
Returns
- Static
Direct reference to the memory backing a static.
Remarks
This is distinct from the this[StaticHandle] indexer in that this returns the direct memory reference. StaticReference includes a layer of indirection that can expose more features.
GetStaticReference(StaticHandle)
Gets a reference to a static by its handle.
public StaticReference GetStaticReference(StaticHandle handle)
Parameters
handle
StaticHandleHandle of the static to grab a reference of.
Returns
- StaticReference
Reference to the desired static.
Remove(StaticHandle)
Removes a static from the set. Any sleeping dynamic bodies with bounding boxes overlapping the removed static's bounding box will be forced active.
public void Remove(StaticHandle handle)
Parameters
handle
StaticHandleHandle of the static to remove.
RemoveAt(int)
Removes a static from the set by index. Any sleeping dynamic bodies with bounding boxes overlapping the removed static's bounding box will be forced active.
public void RemoveAt(int index)
Parameters
index
intIndex of the static to remove.
RemoveAt<TAwakeningFilter>(int, ref TAwakeningFilter)
Removes a static from the set by index. Any sleeping bodies with bounding boxes overlapping the removed static's bounding box and passing the given filter will be forced awake.
public void RemoveAt<TAwakeningFilter>(int index, ref TAwakeningFilter filter) where TAwakeningFilter : struct, IStaticChangeAwakeningFilter
Parameters
index
intIndex of the static to remove.
filter
TAwakeningFilterFilter to apply to sleeping bodies near the removed static to see if they should be awoken.
Type Parameters
TAwakeningFilter
Type of the filter to apply to sleeping bodies.
Remove<TAwakeningFilter>(StaticHandle, ref TAwakeningFilter)
Removes a static from the set. Any sleeping bodies with bounding boxes overlapping the removed static's bounding box and passing the given filter will be forced active.
public void Remove<TAwakeningFilter>(StaticHandle handle, ref TAwakeningFilter filter) where TAwakeningFilter : struct, IStaticChangeAwakeningFilter
Parameters
handle
StaticHandleHandle of the static to remove.
filter
TAwakeningFilterFilter to apply to sleeping bodies near the removed static to see if they should be awoken.
Type Parameters
TAwakeningFilter
Type of the filter to apply to sleeping bodies.
Resize(int)
Resizes the allocated spans for static data. Note that this is conservative; it will never orphan existing objects.
public void Resize(int capacity)
Parameters
capacity
intTarget static data capacity.
SetShape(StaticHandle, TypedIndex)
Changes the shape of a static and updates its bounds in the broad phase. All sleeping dyanmic bodies with bounding boxes overlapping the old or new static collidable are forced active.
public void SetShape(StaticHandle handle, TypedIndex newShape)
Parameters
handle
StaticHandleHandle of the static to change the shape of.
newShape
TypedIndexIndex of the new shape to use for the static.
SetShape<TAwakeningFilter>(StaticHandle, TypedIndex, ref TAwakeningFilter)
Changes the shape of a static and updates its bounds in the broad phase. All sleeping bodies with bounding boxes overlapping the old or new static collidable and pass the given filter are forced active.
public void SetShape<TAwakeningFilter>(StaticHandle handle, TypedIndex newShape, ref TAwakeningFilter filter) where TAwakeningFilter : struct, IStaticChangeAwakeningFilter
Parameters
handle
StaticHandleHandle of the static to change the shape of.
newShape
TypedIndexIndex of the new shape to use for the static.
filter
TAwakeningFilterFilter to apply to sleeping bodies near the static to see if they should be awoken.
Type Parameters
TAwakeningFilter
Type of the filter to apply to sleeping bodies.
StaticExists(StaticHandle)
Checks whether a static handle is currently registered with the statics set.
public bool StaticExists(StaticHandle handle)
Parameters
handle
StaticHandleHandle to check for.
Returns
- bool
True if the handle exists in the collection, false otherwise.
UpdateBounds(StaticHandle)
Updates the bounds held within the broad phase for the static's current state.
public void UpdateBounds(StaticHandle handle)
Parameters
handle
StaticHandle