Class IslandSleeper
- Namespace
- BepuPhysics
- Assembly
- BepuPhysics.dll
public class IslandSleeper
- Inheritance
-
IslandSleeper
- Inherited Members
Constructors
IslandSleeper(Bodies, Solver, BroadPhase, ConstraintRemover, BufferPool)
public IslandSleeper(Bodies bodies, Solver solver, BroadPhase broadPhase, ConstraintRemover constraintRemover, BufferPool pool)
Parameters
bodiesBodiessolverSolverbroadPhaseBroadPhaseconstraintRemoverConstraintRemoverpoolBufferPool
Properties
InitialIslandBodyCapacity
public int InitialIslandBodyCapacity { get; set; }
Property Value
InitialIslandConstraintCapacity
public int InitialIslandConstraintCapacity { get; set; }
Property Value
TargetSleptFraction
Gets or sets the fraction of the active set to target as the number of bodies slept in a given frame. This is only a goal; the actual number of slept bodies may be more or less.
public float TargetSleptFraction { get; set; }
Property Value
TargetTraversedFraction
Gets or sets the fraction of the active set to target as the number of bodies traversed for sleeping in a given frame. This is only a goal; the actual number of traversed bodies may be more or less.
public float TargetTraversedFraction { get; set; }
Property Value
TestedFractionPerFrame
Gets or sets the multiplier applied to the active body count used to calculate the number of sleep traversals in a given timestep.
public float TestedFractionPerFrame { get; set; }
Property Value
Methods
Clear()
public void Clear()
CollectIsland<TTraversalPredicate>(BufferPool, int, ref TTraversalPredicate, ref QuickList<int>, ref QuickList<ConstraintHandle>)
Traverses the active constraint graph collecting bodies that match a predicate. If any body visited during the traversal fails to match the predicate, the traversal terminates.
public bool CollectIsland<TTraversalPredicate>(BufferPool pool, int startingActiveBodyIndex, ref TTraversalPredicate predicate, ref QuickList<int> bodyIndices, ref QuickList<ConstraintHandle> constraintHandles) where TTraversalPredicate : IPredicate<int>
Parameters
poolBufferPoolPool to allocate temporary collections from.
startingActiveBodyIndexintIndex of the active body to start the traversal at.
predicateTTraversalPredicatePredicate to test each traversed body with. If any body results in the predicate returning false, the traversal stops and the function returns false.
bodyIndicesQuickList<int>List to fill with body indices traversed during island collection. Bodies failing the predicate will not be included.
constraintHandlesQuickList<ConstraintHandle>List to fill with constraint handles traversed during island collection.
Returns
- bool
True if the simulation graph was traversed without ever finding a body that made the predicate return false. False if any body failed the predicate. The bodyIndices and constraintHandles lists will contain all traversed predicate-passing bodies and constraints.
Type Parameters
TTraversalPredicateType of the predicate to test each body index with.
Dispose()
public void Dispose()
EnsureSetsCapacity(int)
Ensures that the Bodies, Solver, and NarrowPhase can hold at least the given number of sets (BodySets for the Bodies collection, ConstraintSets for the Solver, PairSubcaches for the NarrowPhase.PairCache).
public void EnsureSetsCapacity(int setsCapacity)
Parameters
setsCapacityintNumber of sets to guarantee space for.
ResizeSetsCapacity(int)
Ensures that the Bodies and Solver can hold the given number of sets. If the existing allocation is smaller than the requested sets capacity, the allocation will be enlarged. If the existing allocation is larger than both the existing potentially allocated set range and the requested sets capacity, the allocation will be shrunk. Shrinks will never cause an existing set to be lost.
public void ResizeSetsCapacity(int setsCapacity)
Parameters
setsCapacityintTarget number of sets to allocate space for.
Sleep(ref QuickList<int>, IThreadDispatcher, bool)
Forcefully sleeps a list of bodies and all bodies that can be reached by traversing the constraint graph from those bodies.
public void Sleep(ref QuickList<int> bodyIndices, IThreadDispatcher threadDispatcher = null, bool deterministic = false)
Parameters
bodyIndicesQuickList<int>List of body indices to sleep.
threadDispatcherIThreadDispatcherThread dispatcher to use for the sleep attempt, if any. If null, sleep is performed on the calling thread.
deterministicboolTrue if the sleep should produce deterministic results at higher cost, false otherwise.
Sleep(int)
Forces a body and all bodies that can be found by traversing the constraint graph from that body to go to sleep.
public void Sleep(int bodyIndex)
Parameters
bodyIndexintIndex of the body to sleep in the active set.