157 JPH_ASSERT(inSplitIslandIndex < mNumSplitIslands);
168 static constexpr uint cSplitCombineTreshold = 32;
169 static constexpr uint cBatchSize = 16;
171 uint32 mNumActiveBodies = 0;
173 SplitMask * mSplitMasks =
nullptr;
175 uint32 * mContactAndConstraintsSplitIdx =
nullptr;
176 uint32 * mContactAndConstraintIndices =
nullptr;
177 uint mContactAndConstraintsSize = 0;
178 atomic<uint> mContactAndConstraintsNextFree { 0 };
180 uint mNumSplitIslands = 0;
181 Splits * mSplitIslands =
nullptr;
182 atomic<uint> mNextSplitIsland = 0;
std::uint64_t uint64
Definition: Core.h:456
unsigned int uint
Definition: Core.h:452
#define JPH_NAMESPACE_END
Definition: Core.h:378
std::uint32_t uint32
Definition: Core.h:455
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:372
#define JPH_ASSERT(...)
Definition: IssueReporting.h:33
ID of a body. This is a way of reasoning about bodies in a multithreaded simulation while avoiding ra...
Definition: BodyID.h:13
Class that contains all bodies.
Definition: BodyManager.h:44
Class used to calculate the total number of velocity and position steps.
Definition: CalculateSolverSteps.h:13
Base class for all physics constraints. A constraint removes one or more degrees of freedom for a rig...
Definition: Constraint.h:103
Keeps track of connected bodies and builds islands for multithreaded velocity/position update.
Definition: IslandBuilder.h:19
Structure that describes the resulting splits from the large island splitter.
Definition: LargeIslandSplitter.h:58
void ResetStatus()
Reset current status so that no work can be picked up from this split.
Definition: LargeIslandSplitter.h:80
EIterationStatus
Definition: LargeIslandSplitter.h:99
@ StatusSplitMask
Definition: LargeIslandSplitter.h:102
@ StatusItemMask
Definition: LargeIslandSplitter.h:104
@ StatusSplitShift
Definition: LargeIslandSplitter.h:103
@ StatusIterationMask
Definition: LargeIslandSplitter.h:100
@ StatusIterationShift
Definition: LargeIslandSplitter.h:101
static uint sGetItem(uint64 inStatus)
Definition: LargeIslandSplitter.h:117
atomic< uint > mItemsProcessed
Number of items that have been marked as processed.
Definition: LargeIslandSplitter.h:129
int mNumPositionSteps
Number of position steps to do.
Definition: LargeIslandSplitter.h:127
void StartFirstBatch()
Make the first batch available to other threads.
Definition: LargeIslandSplitter.h:86
void MarkBatchProcessed(uint inNumProcessed, bool &outLastIteration, bool &outFinalBatch)
Mark a batch as processed.
Definition: LargeIslandSplitter.cpp:120
int mNumIterations
Number of iterations to do.
Definition: LargeIslandSplitter.h:125
void GetConstraintsInSplit(uint inSplitIndex, uint32 &outConstraintsBegin, uint32 &outConstraintsEnd) const
Definition: LargeIslandSplitter.h:65
EStatus FetchNextBatch(uint32 &outConstraintsBegin, uint32 &outConstraintsEnd, uint32 &outContactsBegin, uint32 &outContactsEnd, bool &outFirstIteration)
Fetch the next batch to process.
Definition: LargeIslandSplitter.cpp:19
uint32 mIslandIndex
Index of the island that was split.
Definition: LargeIslandSplitter.h:123
static int sGetIteration(uint64 inStatus)
Definition: LargeIslandSplitter.h:107
uint GetNumSplits() const
Definition: LargeIslandSplitter.h:60
void GetContactsInSplit(uint inSplitIndex, uint32 &outContactsBegin, uint32 &outContactsEnd) const
Definition: LargeIslandSplitter.h:72
Split mSplits[cNumSplits]
Data per split.
Definition: LargeIslandSplitter.h:122
uint mNumSplits
Number of splits that were created (excluding the non-parallel split)
Definition: LargeIslandSplitter.h:124
atomic< uint64 > mStatus
Status of the split, see EIterationStatus.
Definition: LargeIslandSplitter.h:128
int mNumVelocitySteps
Number of velocity steps to do (cached for 2nd sub step)
Definition: LargeIslandSplitter.h:126
static uint sGetSplit(uint64 inStatus)
Definition: LargeIslandSplitter.h:112
Definition: LargeIslandSplitter.h:25
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 ...
Definition: LargeIslandSplitter.cpp:283
uint AssignToNonParallelSplit(const Body *inBody)
Force a body to be in a non parallel split. Returns the split index.
Definition: LargeIslandSplitter.cpp:271
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.
Definition: LargeIslandSplitter.cpp:517
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 Mar...
Definition: LargeIslandSplitter.cpp:487
static constexpr uint cNumSplits
Definition: LargeIslandSplitter.h:30
void Prepare(const IslandBuilder &inIslandBuilder, uint32 inNumActiveBodies, TempAllocator *inTempAllocator)
Prepare the island splitter by allocating memory.
Definition: LargeIslandSplitter.cpp:183
~LargeIslandSplitter()
Destructor.
Definition: LargeIslandSplitter.cpp:175
static constexpr uint cLargeIslandTreshold
If the number of constraints + contacts in an island is larger than this, we will try to split the is...
Definition: LargeIslandSplitter.h:32
uint32 GetIslandIndex(uint inSplitIslandIndex) const
Get the island index of the island that was split for a particular split island index.
Definition: LargeIslandSplitter.h:155
EStatus
Status code for retrieving a batch.
Definition: LargeIslandSplitter.h:36
@ WaitingForBatch
Work is expected to be available later.
@ BatchRetrieved
Work is being returned.
@ AllBatchesDone
No further work is expected from this.
uint AssignSplit(const Body *inBody1, const Body *inBody2)
Assign two bodies to a split. Returns the split index.
Definition: LargeIslandSplitter.cpp:232
void Reset(TempAllocator *inTempAllocator)
Reset the island splitter.
Definition: LargeIslandSplitter.cpp:538
void PrepareForSolvePositions()
Prepare the island splitter for iterating over the split islands again for position solving....
Definition: LargeIslandSplitter.cpp:526
static constexpr uint cNonParallelSplitIdx
Definition: LargeIslandSplitter.h:31
Class that makes another class non-copyable. Usage: Inherit from NonCopyable.
Definition: NonCopyable.h:11
Definition: TempAllocator.h:16
Describes a split of constraints and contacts.
Definition: LargeIslandSplitter.h:44
uint32 mConstraintBufferBegin
Begin of the constraint buffer (offset relative to mContactAndConstraintIndices)
Definition: LargeIslandSplitter.h:52
uint GetNumItems() const
Definition: LargeIslandSplitter.h:47
uint32 mContactBufferEnd
End of the contact buffer.
Definition: LargeIslandSplitter.h:50
uint GetNumConstraints() const
Definition: LargeIslandSplitter.h:46
uint GetNumContacts() const
Definition: LargeIslandSplitter.h:45
uint32 mContactBufferBegin
Begin of the contact buffer (offset relative to mContactAndConstraintIndices)
Definition: LargeIslandSplitter.h:49
uint32 mConstraintBufferEnd
End of the constraint buffer.
Definition: LargeIslandSplitter.h:53