Table of Contents

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

bodies Bodies
solver Solver
broadPhase BroadPhase
constraintRemover ConstraintRemover
pool BufferPool

Properties

InitialIslandBodyCapacity

public int InitialIslandBodyCapacity { get; set; }

Property Value

int

InitialIslandConstraintCapacity

public int InitialIslandConstraintCapacity { get; set; }

Property Value

int

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

float

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

float

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

float

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

pool BufferPool

Pool to allocate temporary collections from.

startingActiveBodyIndex int

Index of the active body to start the traversal at.

predicate TTraversalPredicate

Predicate to test each traversed body with. If any body results in the predicate returning false, the traversal stops and the function returns false.

bodyIndices QuickList<int>

List to fill with body indices traversed during island collection. Bodies failing the predicate will not be included.

constraintHandles QuickList<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

TTraversalPredicate

Type 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

setsCapacity int

Number 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

setsCapacity int

Target 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

bodyIndices QuickList<int>

List of body indices to sleep.

threadDispatcher IThreadDispatcher

Thread dispatcher to use for the sleep attempt, if any. If null, sleep is performed on the calling thread.

deterministic bool

True 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

bodyIndex int

Index of the body to sleep in the active set.