Navigation
API > API/Runtime > API/Runtime/Chaos
The SolverBodies for a set of particles.
Each IslandGroup owns a SolverBodyContainer containing the data required for solving the constraints in the group's islands. Constraints will hold pointers to SolverBodies in the Island's SolverBodyContainer. ConstraintSolvers read and write to their SolverBodies and do not access particles directly.
SolverBodies are created at the start of the constraint solving phase, and destroyed at the end. They are stored in a semi-contiguous (chunked) array in roughly the order that they are accessed for cache efficiency. Pointers to SolverBodies are persistent for the duration of the tick, but no longer.
This container holds all the state of bodies in an island. Dynamics will only appear in one island, but kinematics are in multiple and so their state will be duplicated in each island. This is ok - we do not write to the state of any kinematic bodies in the constraint solvers. We also assume that the number of kinematics is small compared to the number of dynamics. If this is commonly untrue we may want to consider having a separate (global) container of kinematic solver bodies.
| Name | FSolverBodyContainer |
| Type | class |
| Header File | /Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Evolution/SolverBodyContainer.h |
| Include Path | #include "Chaos/Evolution/SolverBodyContainer.h" |
Syntax
class FSolverBodyContainer
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FSolverBodyContainer() |
Chaos/Evolution/SolverBodyContainer.h |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| FSolverBodyArray | Private::TChaosChunkedArray< FSolverBody, BodyArrayChunkSize > | Chaos/Evolution/SolverBodyContainer.h |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| BodyArrayChunkSize | const int32 | Chaos/Evolution/SolverBodyContainer.h | |
| NumBodiesPerChunk | const int32 | Settings for the Solver Body array. | Chaos/Evolution/SolverBodyContainer.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bLocked | bool | To trap incorrect use of the solve bodies. | Chaos/Evolution/SolverBodyContainer.h | |
| Particles | TArray< FGeometryParticleHandle * > | The particles that map to each solver body. | Chaos/Evolution/SolverBodyContainer.h | |
| ParticleToIndexMap | TMap< FGenericParticleHandle, int32 > | Used to determine if a (non-dynamic) body is already present in the container. | Chaos/Evolution/SolverBodyContainer.h | |
| SolverBodies | FSolverBodyArray | All the solver bodies. | Chaos/Evolution/SolverBodyContainer.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void ApplyCorrections() |
Apply accumulated transform deltas to the body transforms. | Chaos/Evolution/SolverBodyContainer.h | |
void CopyTo
(
FSolverBodyContainer& Dest |
Used to AB test solvers - not intended for general use (very expensive!) | Chaos/Evolution/SolverBodyContainer.h | |
FSolverBody * FindOrAdd
(
FGenericParticleHandle InParticle |
Add a solver body to represent the solver state of the particle This should ideally be called in the order in which the bodies will be accessed (or as close as we can get, given most constraints access 2 bodies so there is no perfect order) NOTE: This does not populate the solver body with any data from the particle - we must also call GatherInput for that to happen (GatherInput is highly parallizable but FindOrAdd is not) | Chaos/Evolution/SolverBodyContainer.h | |
void GatherInput
(
const FReal Dt, |
Collect all the data we need from the particles represented by our SolverBodies. | Chaos/Evolution/SolverBodyContainer.h | |
FGeometryParticleHandle * GetParticle
(
const int32 Index |
Get the particle associated with the solver body at Index. | Chaos/Evolution/SolverBodyContainer.h | |
const FSolverBody & GetSolverBody
(
const int32 Index |
Get the solver body at Index. | Chaos/Evolution/SolverBodyContainer.h | |
FSolverBody & GetSolverBody
(
const int32 Index |
Get the solver body at Index. | Chaos/Evolution/SolverBodyContainer.h | |
void Lock () |
Indicate that no more bodies should be added until the next tick (when Reset is called). | Chaos/Evolution/SolverBodyContainer.h | |
int Max() |
The maximum number of bodies the container can hold (until Reset() is called again) | Chaos/Evolution/SolverBodyContainer.h | |
int Num() |
The number of bodies in the container. | Chaos/Evolution/SolverBodyContainer.h | |
void Reset
(
int MaxBodies |
Clear the bodies array and allocate enough space for at least MaxBodies bodies. | Chaos/Evolution/SolverBodyContainer.h | |
void ScatterOutput
(
const int32 BeginIndex, |
Scatter the solver results back to the particles represented by our SolverBodies. Range version used for parallization. | Chaos/Evolution/SolverBodyContainer.h | |
void SetImplicitVelocities
(
FReal Dt |
Recalculate the velocities of all bodies based on their transform deltas. | Chaos/Evolution/SolverBodyContainer.h | |
void UpdateRotationDependentState() |
Can be called after ApplyCorrections to update inertia to match the current transform. | Chaos/Evolution/SolverBodyContainer.h |