p.ClothPhysics.WaitForParallelClothTask
p.ClothPhysics.WaitForParallelClothTask
#Overview
name: p.ClothPhysics.WaitForParallelClothTask
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If 1, always wait for cloth task completion in the Cloth Tick function. If 0, wait at end-of-frame updates instead if allowed by component settings
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.ClothPhysics.WaitForParallelClothTask is to control the synchronization behavior of cloth physics simulation in Unreal Engine 5. It determines whether the engine should wait for the completion of parallel cloth simulation tasks within the Cloth Tick function or defer waiting until end-of-frame updates.
This setting variable is primarily used by the cloth physics system, which is part of the engine’s physics and animation subsystems. It is specifically referenced in the ChaosClothAsset plugin and the Engine’s skeletal mesh component physics module.
The value of this variable is set as a console variable, with a default value of 0. It can be changed at runtime through the console or programmatically.
This variable interacts closely with another variable named CVarClothPhysicsTickWaitForParallelClothTask, which shares the same value and purpose. They are used in conjunction to determine the waiting behavior for cloth simulation tasks.
Developers should be aware that:
- Setting this variable to 1 will force the engine to always wait for cloth task completion within the Cloth Tick function.
- Setting it to 0 (default) will defer waiting to end-of-frame updates if allowed by component settings.
Best practices when using this variable include:
- Use it in conjunction with other cloth-related settings to fine-tune performance and visual quality.
- Be cautious when changing its value, as it can affect frame rates and the responsiveness of cloth simulation.
- Test thoroughly in various scenarios to ensure the chosen setting doesn’t negatively impact performance or visual fidelity.
Regarding the associated variable CVarClothPhysicsTickWaitForParallelClothTask:
This variable serves the same purpose as p.ClothPhysics.WaitForParallelClothTask. It is used in the USkeletalMeshComponent class to determine if the component should wait for cloth simulation results in its tick function.
The value of this variable is set in the same manner as p.ClothPhysics.WaitForParallelClothTask, through the console variable system.
Developers should note that this variable is used in conjunction with a component-specific boolean flag (bWaitForParallelClothTask) to determine the final waiting behavior. This allows for more granular control at the component level.
When working with CVarClothPhysicsTickWaitForParallelClothTask, developers should:
- Understand its interaction with individual component settings.
- Consider the performance implications of waiting for cloth simulation in the tick function versus at end-of-frame updates.
- Use it in tandem with other cloth-related settings to achieve the desired balance between performance and visual quality.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SkeletalMeshComponentPhysics.cpp:51
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarEnableClothPhysicsUseTaskThread(TEXT("p.ClothPhysics.UseTaskThread"), 1, TEXT("If 1, run cloth on the task thread. If 0, run on game thread."));
static TAutoConsoleVariable<int32> CVarClothPhysicsTickWaitForParallelClothTask(TEXT("p.ClothPhysics.WaitForParallelClothTask"), 0, TEXT("If 1, always wait for cloth task completion in the Cloth Tick function. If 0, wait at end-of-frame updates instead if allowed by component settings"));
static TAutoConsoleVariable<bool> CVarClothTeleportOverride(TEXT("p.Cloth.TeleportOverride"), false, TEXT("Force console variable teleport override values over skeletal mesh properties.\n Default: false."));
static TAutoConsoleVariable<bool> CVarClothResetAfterTeleport(TEXT("p.Cloth.ResetAfterTeleport"), true, TEXT("Require p.Cloth.TeleportOverride. Reset the clothing after moving the clothing position (called teleport).\n Default: true."));
static TAutoConsoleVariable<float> CVarClothTeleportDistanceThreshold(TEXT("p.Cloth.TeleportDistanceThreshold"), 300.f, TEXT("Require p.Cloth.TeleportOverride. Conduct teleportation if the character's movement is greater than this threshold in 1 frame.\n Zero or negative values will skip the check.\n Default: 300."));
static TAutoConsoleVariable<float> CVarClothTeleportRotationThreshold(TEXT("p.Cloth.TeleportRotationThreshold"), 0.f, TEXT("Require p.Cloth.TeleportOverride. Rotation threshold in degrees, ranging from 0 to 180.\n Conduct teleportation if the character's rotation is greater than this threshold in 1 frame.\n Zero or negative values will skip the check.\n Default 0."));
#Loc: <Workspace>/Engine/Plugins/ChaosClothAsset/Source/ChaosClothAssetEngine/Private/ChaosClothAsset/ClothComponent.cpp:473
Scope (from outer to inner):
file
function bool UChaosClothComponent::ShouldWaitForParallelSimulationInTickComponent
Source code excerpt:
bool UChaosClothComponent::ShouldWaitForParallelSimulationInTickComponent() const
{
static IConsoleVariable* const CVarClothPhysicsWaitForParallelClothTask = IConsoleManager::Get().FindConsoleVariable(TEXT("p.ClothPhysics.WaitForParallelClothTask"));
return bWaitForParallelTask || (CVarClothPhysicsWaitForParallelClothTask && CVarClothPhysicsWaitForParallelClothTask->GetBool());
}
void UChaosClothComponent::UpdateComponentSpaceTransforms()
{
#Associated Variable and Callsites
This variable is associated with another variable named CVarClothPhysicsTickWaitForParallelClothTask
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SkeletalMeshComponentPhysics.cpp:51
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarEnableClothPhysicsUseTaskThread(TEXT("p.ClothPhysics.UseTaskThread"), 1, TEXT("If 1, run cloth on the task thread. If 0, run on game thread."));
static TAutoConsoleVariable<int32> CVarClothPhysicsTickWaitForParallelClothTask(TEXT("p.ClothPhysics.WaitForParallelClothTask"), 0, TEXT("If 1, always wait for cloth task completion in the Cloth Tick function. If 0, wait at end-of-frame updates instead if allowed by component settings"));
static TAutoConsoleVariable<bool> CVarClothTeleportOverride(TEXT("p.Cloth.TeleportOverride"), false, TEXT("Force console variable teleport override values over skeletal mesh properties.\n Default: false."));
static TAutoConsoleVariable<bool> CVarClothResetAfterTeleport(TEXT("p.Cloth.ResetAfterTeleport"), true, TEXT("Require p.Cloth.TeleportOverride. Reset the clothing after moving the clothing position (called teleport).\n Default: true."));
static TAutoConsoleVariable<float> CVarClothTeleportDistanceThreshold(TEXT("p.Cloth.TeleportDistanceThreshold"), 300.f, TEXT("Require p.Cloth.TeleportOverride. Conduct teleportation if the character's movement is greater than this threshold in 1 frame.\n Zero or negative values will skip the check.\n Default: 300."));
static TAutoConsoleVariable<float> CVarClothTeleportRotationThreshold(TEXT("p.Cloth.TeleportRotationThreshold"), 0.f, TEXT("Require p.Cloth.TeleportOverride. Rotation threshold in degrees, ranging from 0 to 180.\n Conduct teleportation if the character's rotation is greater than this threshold in 1 frame.\n Zero or negative values will skip the check.\n Default 0."));
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SkeletalMeshComponentPhysics.cpp:3743
Scope (from outer to inner):
file
function bool USkeletalMeshComponent::ShouldWaitForClothInTickFunction
Source code excerpt:
bool USkeletalMeshComponent::ShouldWaitForClothInTickFunction() const
{
return bWaitForParallelClothTask || (CVarClothPhysicsTickWaitForParallelClothTask.GetValueOnAnyThread() != 0);
}
const TMap<int32, FClothSimulData>& USkeletalMeshComponent::GetCurrentClothingData_GameThread() const
{
// We require the cloth tick to wait for the simulation results if we want to use them for some reason other than rendering.
if (!ShouldWaitForClothInTickFunction())