Navigation
API > API/Runtime > API/Runtime/Chaos
All constraint pointers are persistent in memory until Destroy() is called, or until they are pruned.
This allocator maintains the set of all overlapping particle pairs, with each overlapping particle pair managed by a FParticlePairMidPhase object. the MidPhase object is what actually calls the Narrow Phase and maintains the set of collision constraints for all the shape pairs on the particles.
Constraints are allocated during the collision detection phase and retained between ticks. An attempt to create a constraint for the same shape pair as seen on the previous tick will return the existing collision constraint with all of its data intact.
The allocator also keeps a list of Standard and Swept collision constraints that are active for the current tick. This list gets reset and rebuilt every frame during collision detection. It may get added to by the IslandManager if some islands are woken following collision detection.
The allocators Epoch counter is used to determine whether a constraint (or midphase object) generated any contacts for the current frame. When a midphase creates or updates a constraint, it copies the current Epoch counter.
The Midphase list is pruned at the end of each tick so if particles are destroyed or a particle pair is no longer overlapping, the collisions will be destroyed.
When particles are destroyed, we do not immediately destroy the MidPhases (or Collisions) that are associoated with the particle. Instead, we clear the particle pointer from them, but leave their destruction to the pruning process. This avoids the need to parse collision and midphase lists whenever a particle is disabled.
NOTE: To reduce RBAN memory use, we do not create any collision blocks until the first call to CreateCollisionConstraint (see ConstraintPool initialization)
| Name | FCollisionConstraintAllocator |
| Type | class |
| Header File | /Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Collision/CollisionConstraintAllocator.h |
| Include Path | #include "Chaos/Collision/CollisionConstraintAllocator.h" |
Syntax
class FCollisionConstraintAllocator
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Chaos/Collision/CollisionConstraintAllocator.h | |||
| Chaos/Collision/CollisionConstraintAllocator.h | |||
FCollisionConstraintAllocator
(
const int32 InNumCollisionsPerBlock |
Chaos/Collision/CollisionConstraintAllocator.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
~FCollisionConstraintAllocator() |
Chaos/Collision/CollisionConstraintAllocator.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| ActiveCCDConstraints | TArray< FPBDCollisionConstraint * > | The active sweep constraints (added or recovered this tick) | Chaos/Collision/CollisionConstraintAllocator.h | |
| ActiveConstraints | TArray< FPBDCollisionConstraint * > | The active constraints (added or recovered this tick) | Chaos/Collision/CollisionConstraintAllocator.h | |
| bInCollisionDetectionPhase | bool | For assertions. | Chaos/Collision/CollisionConstraintAllocator.h | |
| bIsDeteministic | bool | Whether we running a deterministic sim. | Chaos/Collision/CollisionConstraintAllocator.h | |
| CollisionContainer | FPBDCollisionConstraints * | The container that owns the allocator (only needed because new constraints need to know) | Chaos/Collision/CollisionConstraintAllocator.h | |
| ContextAllocators | TArray< TUniquePtr< FCollisionContextAllocator > > | Storage for collisins and midphases, one for each thread on which we detect collisions. | Chaos/Collision/CollisionConstraintAllocator.h | |
| CurrentEpoch | int32 | The current epoch used to track out-of-date contacts. | Chaos/Collision/CollisionConstraintAllocator.h | |
| NumCollisionsPerBlock | int32 | Chaos/Collision/CollisionConstraintAllocator.h | ||
| ParticlePairMidPhases | TArray< FParticlePairMidPhasePtr > | All of the overlapping particle pairs in the scene. | Chaos/Collision/CollisionConstraintAllocator.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void AddActiveConstraint
(
FPBDCollisionConstraint* Constraint |
This should be called when a sleeping constraint is activated after the narrow phase, typically in the island manager. | Chaos/Collision/CollisionConstraintAllocator.h | |
void AddResimConstraints
(
const TArray< FPBDCollisionConstraint >& InConstraints, |
Add a set of pre-built constraints and build required internal mapping data This is used by the resim cache when restoring constraints after a desync. | Chaos/Collision/CollisionConstraintAllocator.h | |
void BeginDetectCollisions() |
Called at the start of the tick to prepare for collision detection. Resets the list of active contacts. | Chaos/Collision/CollisionConstraintAllocator.h | |
void BeginFrame() |
Called at the start of the frame to clear the frame's active collision list. | Chaos/Collision/CollisionConstraintAllocator.h | |
void EndDetectCollisions() |
Called after collision detection to clean up Prunes unused contacts. | Chaos/Collision/CollisionConstraintAllocator.h | |
TArrayView< FPBDCollisionConstraint *const > GetCCDConstraints () |
The set of sweep collision constraints for the current tick (created or reinstated) | Chaos/Collision/CollisionConstraintAllocator.h | |
TArrayView< const FPBDCollisionConstraint *const > GetConstConstraints () |
The set of collision constraints for the current tick (created or reinstated) | Chaos/Collision/CollisionConstraintAllocator.h | |
TArrayView< FPBDCollisionConstraint *const > GetConstraints () |
The set of collision constraints for the current tick (created or reinstated) | Chaos/Collision/CollisionConstraintAllocator.h | |
FCollisionContextAllocator * GetContextAllocator
(
const int32 Index |
Chaos/Collision/CollisionConstraintAllocator.h | ||
int32 GetCurrentEpoch() |
Chaos/Collision/CollisionConstraintAllocator.h | ||
bool IsConstraintExpired
(
const FPBDCollisionConstraint& Constraint |
Has the constraint expired. | Chaos/Collision/CollisionConstraintAllocator.h | |
void ProcessInjectedConstraints() |
If we add new constraints after collision detection, do what needs to be done to add them to the system. | Chaos/Collision/CollisionConstraintAllocator.h | |
void ProcessNewMidPhases() |
Collect all the midphases created on the context allocators (probably on multiple threads) and register them | Chaos/Collision/CollisionConstraintAllocator.h | |
void PruneExpiredItems() |
Called each tick after the graph is updated to remove unused collisions. | Chaos/Collision/CollisionConstraintAllocator.h | |
void RemoveParticle
(
FGeometryParticleHandle* Particle |
Destroy all collision and caches involving the particle Called when a particle is destroyed or disabled (not sleeping). | Chaos/Collision/CollisionConstraintAllocator.h | |
void Reset() |
Destroy all constraints. | Chaos/Collision/CollisionConstraintAllocator.h | |
void SetCollisionContainer
(
FPBDCollisionConstraints* InCollisionContainer |
Chaos/Collision/CollisionConstraintAllocator.h | ||
void SetIsDeterministic
(
const bool bInIsDeterministic |
Enable/Disable determinism (extra sorting steps after collision detection) | Chaos/Collision/CollisionConstraintAllocator.h | |
void SetMaxContexts
(
const int32 MaxContexts |
Chaos/Collision/CollisionConstraintAllocator.h | ||
void SortConstraintsHandles() |
Sort all the constraints for better solver stability. | Chaos/Collision/CollisionConstraintAllocator.h | |
void VisitCollisions
(
const TLambda& Visitor |
Iterate over all collisions (write-enabled), including sleeping ones Visitor signature: ECollisionVisitorResult(FPBDCollisionConstraint&) | Chaos/Collision/CollisionConstraintAllocator.h | |
void VisitConstCollisions
(
const TLambda& Visitor, |
Iterate over all collisions (read-only), including sleeping ones Visitor signature: ECollisionVisitorResult(const FPBDCollisionConstraint&) | Chaos/Collision/CollisionConstraintAllocator.h | |
void VisitMidPhases
(
const TLambda& Visitor |
Iterate over all midphases Visitor signature: ECollisionVisitorResult(FParticlePairMidPhase&) | Chaos/Collision/CollisionConstraintAllocator.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Chaos/Collision/CollisionConstraintAllocator.h | |||
| Chaos/Collision/CollisionConstraintAllocator.h |