Class CollidableProperty<T>
- Namespace
- BepuPhysics
- Assembly
- BepuPhysics.dll
Convenience collection that stores extra properties about bodies and statics, indexed by the body or static handle.
public class CollidableProperty<T> : IDisposable where T : unmanaged
Type Parameters
TType of the data to store.
- Inheritance
-
CollidableProperty<T>
- Implements
- Inherited Members
Remarks
This is built for use cases relying on random access like the narrow phase. For maximum performance with sequential access, an index-aligned structure would be better.
Constructors
CollidableProperty(Simulation, BufferPool)
Constructs a new collection to store handle-aligned body and static properties.
public CollidableProperty(Simulation simulation, BufferPool pool = null)
Parameters
simulationSimulationSimulation to track.
poolBufferPoolPool from which to pull internal resources. If null, uses the Simulation pool.
CollidableProperty(BufferPool)
Constructs a new collection to store handle-aligned body properties. Assumes the Initialize function will be called later to provide the Bodies collection.
public CollidableProperty(BufferPool pool = null)
Parameters
poolBufferPoolPool from which to pull internal resources. If null, uses the later Initialize-provided Bodies pool.
Properties
this[BodyHandle]
Gets a reference to the properties associated with a body's handle.
public ref T this[BodyHandle bodyHandle] { get; }
Parameters
bodyHandleBodyHandleBody handle to retrieve the properties for.
Property Value
- T
Reference to properties associated with a body handle.
this[CollidableReference]
Gets a reference to the properties associated with a collidable.
public ref T this[CollidableReference collidable] { get; }
Parameters
collidableCollidableReferenceCollidable to retrieve the properties for.
Property Value
- T
Reference to properties associated with a collidable.
this[StaticHandle]
Gets a reference to the properties associated with a static's handle.
public ref T this[StaticHandle staticHandle] { get; }
Parameters
staticHandleStaticHandleStatic handle to retrieve the properties for.
Property Value
- T
Reference to properties associated with a static handle.
Methods
Allocate(BodyHandle)
Ensures there is space for a given body handle and returns a reference to the used memory.
public ref T Allocate(BodyHandle bodyHandle)
Parameters
bodyHandleBodyHandleBody handle to allocate for.
Returns
- T
Reference to the data for the given body.
Allocate(CollidableReference)
Ensures there is space for a given collidable reference and returns a reference to the used memory.
public ref T Allocate(CollidableReference collidableReference)
Parameters
collidableReferenceCollidableReferenceCollidable reference to allocate for.
Returns
- T
Reference to the data for the given collidable.
Allocate(StaticHandle)
Ensures there is space for a given static handle and returns a reference to the used memory.
public ref T Allocate(StaticHandle handle)
Parameters
handleStaticHandleStatic handle to allocate for.
Returns
- T
Reference to the data for the given static.
CompactBodies()
Compacts the memory used by the collection for bodies to a safe minimum based on the Bodies collection.
public void CompactBodies()
CompactStatics()
Compacts the memory used by the collection for statics to a safe minimum based on the Statics collection.
public void CompactStatics()
Dispose()
Returns all held resources.
public void Dispose()
EnsureBodyCapacity(int)
Ensures that the internal structures have at least the given capacity for bodies.
public void EnsureBodyCapacity(int capacity)
Parameters
capacityintCapacity to ensure.
EnsureStaticCapacity(int)
Ensures that the internal structures have at least the given capacity for statics.
public void EnsureStaticCapacity(int capacity)
Parameters
capacityintCapacity to ensure.
Initialize(Simulation)
Initializes the property collection if the Bodies/Statics-less constructor was used.
public void Initialize(Simulation simulation)
Parameters
simulationSimulationSimulation whose bodies and statics will be tracked.