Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
LargeIslandSplitter Class Reference

#include <LargeIslandSplitter.h>

Inheritance diagram for LargeIslandSplitter:
NonCopyable

Classes

struct  Split
 Describes a split of constraints and contacts. More...
 
class  Splits
 Structure that describes the resulting splits from the large island splitter. More...
 

Public Types

enum class  EStatus { WaitingForBatch , BatchRetrieved , AllBatchesDone }
 Status code for retrieving a batch. More...
 

Public Member Functions

 ~LargeIslandSplitter ()
 Destructor. More...
 
void Prepare (const IslandBuilder &inIslandBuilder, uint32 inNumActiveBodies, TempAllocator *inTempAllocator)
 Prepare the island splitter by allocating memory. More...
 
uint AssignSplit (const Body *inBody1, const Body *inBody2)
 Assign two bodies to a split. Returns the split index. More...
 
uint AssignToNonParallelSplit (const Body *inBody)
 Force a body to be in a non parallel split. Returns the split index. More...
 
bool SplitIsland (uint32 inIslandIndex, const IslandBuilder &inIslandBuilder, const BodyManager &inBodyManager, const ContactConstraintManager &inContactManager, Constraint **inActiveConstraints, CalculateSolverSteps &ioStepsCalculator)
 Splits up an island, the created splits will be added to the list of batches and can be fetched with FetchNextBatch. Returns false if the island did not need splitting. More...
 
EStatus FetchNextBatch (uint &outSplitIslandIndex, uint32 *&outConstraintsBegin, uint32 *&outConstraintsEnd, uint32 *&outContactsBegin, uint32 *&outContactsEnd, bool &outFirstIteration)
 Fetch the next batch to process, returns a handle in outSplitIslandIndex that must be provided to MarkBatchProcessed when complete. More...
 
void MarkBatchProcessed (uint inSplitIslandIndex, const uint32 *inConstraintsBegin, const uint32 *inConstraintsEnd, const uint32 *inContactsBegin, const uint32 *inContactsEnd, bool &outLastIteration, bool &outFinalBatch)
 Mark a batch as processed. More...
 
uint32 GetIslandIndex (uint inSplitIslandIndex) const
 Get the island index of the island that was split for a particular split island index. More...
 
void PrepareForSolvePositions ()
 Prepare the island splitter for iterating over the split islands again for position solving. Marks all batches as startable. More...
 
void Reset (TempAllocator *inTempAllocator)
 Reset the island splitter. More...
 
- Public Member Functions inherited from NonCopyable
 NonCopyable ()=default
 
 NonCopyable (const NonCopyable &)=delete
 
void operator= (const NonCopyable &)=delete
 

Static Public Attributes

static constexpr uint cNumSplits = sizeof(SplitMask) * 8
 
static constexpr uint cNonParallelSplitIdx = cNumSplits - 1
 
static constexpr uint cLargeIslandTreshold = 128
 If the number of constraints + contacts in an island is larger than this, we will try to split the island. More...
 

Detailed Description

Assigns bodies in large islands to multiple groups that can run in parallel

This basically implements what is described in: High-Performance Physical Simulations on Next-Generation Architecture with Many Cores by Chen et al. See: http://web.eecs.umich.edu/~msmelyan/papers/physsim_onmanycore_itj.pdf section "PARALLELIZATION METHODOLOGY"

Member Enumeration Documentation

◆ EStatus

enum class LargeIslandSplitter::EStatus
strong

Status code for retrieving a batch.

Enumerator
WaitingForBatch 

Work is expected to be available later.

BatchRetrieved 

Work is being returned.

AllBatchesDone 

No further work is expected from this.

Constructor & Destructor Documentation

◆ ~LargeIslandSplitter()

LargeIslandSplitter::~LargeIslandSplitter ( )

Destructor.

Member Function Documentation

◆ AssignSplit()

uint LargeIslandSplitter::AssignSplit ( const Body inBody1,
const Body inBody2 
)

Assign two bodies to a split. Returns the split index.

◆ AssignToNonParallelSplit()

uint LargeIslandSplitter::AssignToNonParallelSplit ( const Body inBody)

Force a body to be in a non parallel split. Returns the split index.

◆ FetchNextBatch()

LargeIslandSplitter::EStatus LargeIslandSplitter::FetchNextBatch ( uint outSplitIslandIndex,
uint32 *&  outConstraintsBegin,
uint32 *&  outConstraintsEnd,
uint32 *&  outContactsBegin,
uint32 *&  outContactsEnd,
bool &  outFirstIteration 
)

Fetch the next batch to process, returns a handle in outSplitIslandIndex that must be provided to MarkBatchProcessed when complete.

◆ GetIslandIndex()

uint32 LargeIslandSplitter::GetIslandIndex ( uint  inSplitIslandIndex) const
inline

Get the island index of the island that was split for a particular split island index.

◆ MarkBatchProcessed()

void LargeIslandSplitter::MarkBatchProcessed ( uint  inSplitIslandIndex,
const uint32 inConstraintsBegin,
const uint32 inConstraintsEnd,
const uint32 inContactsBegin,
const uint32 inContactsEnd,
bool &  outLastIteration,
bool &  outFinalBatch 
)

Mark a batch as processed.

◆ Prepare()

void LargeIslandSplitter::Prepare ( const IslandBuilder inIslandBuilder,
uint32  inNumActiveBodies,
TempAllocator inTempAllocator 
)

Prepare the island splitter by allocating memory.

◆ PrepareForSolvePositions()

void LargeIslandSplitter::PrepareForSolvePositions ( )

Prepare the island splitter for iterating over the split islands again for position solving. Marks all batches as startable.

◆ Reset()

void LargeIslandSplitter::Reset ( TempAllocator inTempAllocator)

Reset the island splitter.

◆ SplitIsland()

bool LargeIslandSplitter::SplitIsland ( uint32  inIslandIndex,
const IslandBuilder inIslandBuilder,
const BodyManager inBodyManager,
const ContactConstraintManager inContactManager,
Constraint **  inActiveConstraints,
CalculateSolverSteps ioStepsCalculator 
)

Splits up an island, the created splits will be added to the list of batches and can be fetched with FetchNextBatch. Returns false if the island did not need splitting.

Member Data Documentation

◆ cLargeIslandTreshold

constexpr uint LargeIslandSplitter::cLargeIslandTreshold = 128
staticconstexpr

If the number of constraints + contacts in an island is larger than this, we will try to split the island.

◆ cNonParallelSplitIdx

constexpr uint LargeIslandSplitter::cNonParallelSplitIdx = cNumSplits - 1
staticconstexpr

◆ cNumSplits

constexpr uint LargeIslandSplitter::cNumSplits = sizeof(SplitMask) * 8
staticconstexpr

The documentation for this class was generated from the following files: