![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
An allocator and container of collision constraints that supports reuse of constraints from the previous tick. More...
#include <CollisionConstraintAllocator.h>
Public Member Functions | |
| UE_NONCOPYABLE (FCollisionConstraintAllocator) | |
| FCollisionConstraintAllocator (const int32 InNumCollisionsPerBlock=1000) | |
| ~FCollisionConstraintAllocator () | |
| void | SetCollisionContainer (FPBDCollisionConstraints *InCollisionContainer) |
| void | SetMaxContexts (const int32 MaxContexts) |
| FCollisionContextAllocator * | GetContextAllocator (const int32 Index) |
| TArrayView< FPBDCollisionConstraint *const > | GetConstraints () const |
| The set of collision constraints for the current tick (created or reinstated) | |
| TArrayView< FPBDCollisionConstraint *const > | GetCCDConstraints () const |
| The set of sweep collision constraints for the current tick (created or reinstated) | |
| TArrayView< const FPBDCollisionConstraint *const > | GetConstConstraints () const |
| The set of collision constraints for the current tick (created or reinstated) | |
| int32 | GetCurrentEpoch () const |
| bool | IsConstraintExpired (const FPBDCollisionConstraint &Constraint) |
| void | Reset () |
| Destroy all constraints. | |
| void | BeginFrame () |
| Called at the start of the frame to clear the frame's active collision list. | |
| void | BeginDetectCollisions () |
| Called at the start of the tick to prepare for collision detection. Resets the list of active contacts. | |
| CHAOS_API void | EndDetectCollisions () |
| Called after collision detection to clean up Prunes unused contacts. | |
| void | PruneExpiredItems () |
| Called each tick after the graph is updated to remove unused collisions. | |
| CHAOS_API void | ProcessNewMidPhases () |
| void | ProcessInjectedConstraints () |
| If we add new constraints after collision detection, do what needs to be done to add them to the system. | |
| void | AddActiveConstraint (FPBDCollisionConstraint *Constraint) |
| void | AddResimConstraints (const TArray< FPBDCollisionConstraint > &InConstraints, const FCollisionContext Context) |
| 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. | |
| void | SortConstraintsHandles () |
| Sort all the constraints for better solver stability. | |
| CHAOS_API void | RemoveParticle (FGeometryParticleHandle *Particle) |
| Destroy all collision and caches involving the particle Called when a particle is destroyed or disabled (not sleeping). | |
| template<typename TLambda > | |
| void | VisitConstCollisions (const TLambda &Visitor, const ECollisionVisitorFlags &VisitFlags=ECollisionVisitorFlags::VisitDefault) const |
| Iterate over all collisions (read-only), including sleeping ones Visitor signature: ECollisionVisitorResult(const FPBDCollisionConstraint&) | |
| template<typename TLambda > | |
| void | VisitCollisions (const TLambda &Visitor) const |
| Iterate over all collisions (write-enabled), including sleeping ones Visitor signature: ECollisionVisitorResult(FPBDCollisionConstraint&) | |
| template<typename TLambda > | |
| void | VisitMidPhases (const TLambda &Visitor) |
| Iterate over all midphases Visitor signature: ECollisionVisitorResult(FParticlePairMidPhase&) | |
| void | SetIsDeterministic (const bool bInIsDeterministic) |
Friends | |
| class | FCollisionContextAllocator |
An allocator and container of collision constraints that supports reuse of constraints from the previous tick.
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)
|
inline |
|
inline |
| void Chaos::Private::FCollisionConstraintAllocator::AddActiveConstraint | ( | FPBDCollisionConstraint * | Constraint | ) |
This should be called when a sleeping constraint is activated after the narrow phase, typically in the island manager. This is mainly so that any systems asking for a list of active constraints are provided all constraints that may have contributed to the simulation, including those that were added when an island is awoken.
|
inline |
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.
|
inline |
Called at the start of the tick to prepare for collision detection. Resets the list of active contacts.
|
inline |
Called at the start of the frame to clear the frame's active collision list.
| void Chaos::Private::FCollisionConstraintAllocator::EndDetectCollisions | ( | ) |
Called after collision detection to clean up Prunes unused contacts.
|
inline |
The set of sweep collision constraints for the current tick (created or reinstated)
|
inline |
The set of collision constraints for the current tick (created or reinstated)
|
inline |
The set of collision constraints for the current tick (created or reinstated)
|
inline |
|
inline |
|
inline |
Has the constraint expired. An expired constraint is one that was not refreshed this tick.
|
inline |
If we add new constraints after collision detection, do what needs to be done to add them to the system.
| void Chaos::Private::FCollisionConstraintAllocator::ProcessNewMidPhases | ( | ) |
Collect all the midphases created on the context allocators (probably on multiple threads) and register them
|
inline |
Called each tick after the graph is updated to remove unused collisions.
| void Chaos::Private::FCollisionConstraintAllocator::RemoveParticle | ( | FGeometryParticleHandle * | Particle | ) |
Destroy all collision and caches involving the particle Called when a particle is destroyed or disabled (not sleeping).
|
inline |
Destroy all constraints.
|
inline |
|
inline |
Enable/Disable determinism (extra sorting steps after collision detection)
|
inline |
|
inline |
Sort all the constraints for better solver stability.
| Chaos::Private::FCollisionConstraintAllocator::UE_NONCOPYABLE | ( | FCollisionConstraintAllocator | ) |
|
inline |
Iterate over all collisions (write-enabled), including sleeping ones Visitor signature: ECollisionVisitorResult(FPBDCollisionConstraint&)
|
inline |
Iterate over all collisions (read-only), including sleeping ones Visitor signature: ECollisionVisitorResult(const FPBDCollisionConstraint&)
|
inline |
Iterate over all midphases Visitor signature: ECollisionVisitorResult(FParticlePairMidPhase&)
|
friend |