p.ChaosCloth.Solver.DebugHitchLength
p.ChaosCloth.Solver.DebugHitchLength
#Overview
name: p.ChaosCloth.Solver.DebugHitchLength
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Hitch length in ms. Create artificial hitches to debug simulation jitter. 0 to disable
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.ChaosCloth.Solver.DebugHitchLength is to introduce artificial hitches in the Chaos Cloth simulation for debugging simulation jitter. It is part of the Chaos Cloth system in Unreal Engine 5, which is responsible for cloth simulation.
This setting variable is used within the ChaosCloth plugin, specifically in the ChaosClothingSimulationSolver module. It is primarily used in the Update function of the FClothingSimulationSolver class.
The value of this variable is set through a console variable (CVar) system, which allows for runtime modification. It is defined using FAutoConsoleVariableRef, making it accessible and modifiable during development and debugging.
This variable interacts closely with another variable called ClothSolverDebugHitchInterval. Together, they control the frequency and duration of artificial hitches in the simulation.
Developers should be aware that:
- This variable is only active in non-shipping builds (#if !UE_BUILD_SHIPPING).
- It represents the hitch length in milliseconds.
- It works in conjunction with ClothSolverDebugHitchInterval to create periodic hitches.
- Setting it to 0 disables the artificial hitches.
Best practices when using this variable include:
- Only use it for debugging purposes, not in production builds.
- Be cautious when setting high values, as it can significantly impact performance.
- Always reset it to 0 after debugging to ensure normal simulation behavior.
Regarding the associated variable ClothSolverDebugHitchLength: This is the actual integer variable that stores the hitch length value. It is used in the same way as p.ChaosCloth.Solver.DebugHitchLength, but it’s the internal representation of the console variable. It’s initialized to 0 by default, meaning no artificial hitches are introduced unless explicitly set. The same considerations and best practices apply to this variable as to its console variable counterpart.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationSolver.cpp:66
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
FAutoConsoleVariableRef CVarClothSolverParallelClothUpdate(TEXT("p.ChaosCloth.Solver.ParallelClothUpdate"), bClothSolverParallelClothUpdate, TEXT("Skin the physics mesh and do the other cloth update for each cloth in parallel."));
FAutoConsoleVariableRef CVarClothSolverParallelClothPostUpdate(TEXT("p.ChaosCloth.Solver.ParallelClothPostUpdate"), bClothSolverParallelClothPostUpdate, TEXT("Pre-transform the cloth particles for each cloth in parallel."));
FAutoConsoleVariableRef CVarClothSolverDebugHitchLength(TEXT("p.ChaosCloth.Solver.DebugHitchLength"), ClothSolverDebugHitchLength, TEXT("Hitch length in ms. Create artificial hitches to debug simulation jitter. 0 to disable"));
FAutoConsoleVariableRef CVarClothSolverDebugHitchInterval(TEXT("p.ChaosCloth.Solver.DebugHitchInterval"), ClothSolverDebugHitchInterval, TEXT("Hitch interval in frames. Create artificial hitches to debug simulation jitter. 0 to disable"));
FAutoConsoleVariableRef CVarClothSolverDisableCollision(TEXT("p.ChaosCloth.Solver.DisableCollision"), bClothSolverDisableCollision, TEXT("Disable all collision particles. Needs reset of the simulation (p.ChaosCloth.Reset)."));
#endif
FAutoConsoleVariableRef CVarClothSolverDisableTimeDependentNumIterations(TEXT("p.ChaosCloth.Solver.DisableTimeDependentNumIterations"), bClothSolverDisableTimeDependentNumIterations, TEXT("Make the number of iterations independent from the time step."));
FAutoConsoleVariableRef CVarClothSolverUseVelocityScale(TEXT("p.ChaosCloth.Solver.UseVelocityScale"), bClothSolverUseVelocityScale, TEXT("Use the velocity scale to compensate for clamping to MaxPhysicsDelta, in order to avoid miscalculating velocities during hitches."));
#Associated Variable and Callsites
This variable is associated with another variable named ClothSolverDebugHitchLength
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationSolver.cpp:58
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
#if !UE_BUILD_SHIPPING
static int32 ClothSolverDebugHitchLength = 0;
static int32 ClothSolverDebugHitchInterval = 0;
static bool bClothSolverDisableCollision = false;
FAutoConsoleVariableRef CVarClothSolverMinParallelBatchSize(TEXT("p.ChaosCloth.Solver.MinParallelBatchSize"), ClothSolverMinParallelBatchSize, TEXT("The minimum number of particle to process in parallel batch by the solver."));
FAutoConsoleVariableRef CVarClothSolverParallelClothPreUpdate(TEXT("p.ChaosCloth.Solver.ParallelClothPreUpdate"), bClothSolverParallelClothPreUpdate, TEXT("Pre-transform the cloth particles for each cloth in parallel."));
FAutoConsoleVariableRef CVarClothSolverParallelClothUpdate(TEXT("p.ChaosCloth.Solver.ParallelClothUpdate"), bClothSolverParallelClothUpdate, TEXT("Skin the physics mesh and do the other cloth update for each cloth in parallel."));
FAutoConsoleVariableRef CVarClothSolverParallelClothPostUpdate(TEXT("p.ChaosCloth.Solver.ParallelClothPostUpdate"), bClothSolverParallelClothPostUpdate, TEXT("Pre-transform the cloth particles for each cloth in parallel."));
FAutoConsoleVariableRef CVarClothSolverDebugHitchLength(TEXT("p.ChaosCloth.Solver.DebugHitchLength"), ClothSolverDebugHitchLength, TEXT("Hitch length in ms. Create artificial hitches to debug simulation jitter. 0 to disable"));
FAutoConsoleVariableRef CVarClothSolverDebugHitchInterval(TEXT("p.ChaosCloth.Solver.DebugHitchInterval"), ClothSolverDebugHitchInterval, TEXT("Hitch interval in frames. Create artificial hitches to debug simulation jitter. 0 to disable"));
FAutoConsoleVariableRef CVarClothSolverDisableCollision(TEXT("p.ChaosCloth.Solver.DisableCollision"), bClothSolverDisableCollision, TEXT("Disable all collision particles. Needs reset of the simulation (p.ChaosCloth.Reset)."));
#endif
FAutoConsoleVariableRef CVarClothSolverDisableTimeDependentNumIterations(TEXT("p.ChaosCloth.Solver.DisableTimeDependentNumIterations"), bClothSolverDisableTimeDependentNumIterations, TEXT("Make the number of iterations independent from the time step."));
FAutoConsoleVariableRef CVarClothSolverUseVelocityScale(TEXT("p.ChaosCloth.Solver.UseVelocityScale"), bClothSolverUseVelocityScale, TEXT("Use the velocity scale to compensate for clamping to MaxPhysicsDelta, in order to avoid miscalculating velocities during hitches."));
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationSolver.cpp:1880
Scope (from outer to inner):
file
namespace Chaos
function void FClothingSimulationSolver::Update
Source code excerpt:
#if !UE_BUILD_SHIPPING
// Introduce artificial hitches for debugging any simulation jitter
if (ClothSolverDebugHitchLength && ClothSolverDebugHitchInterval)
{
static int32 HitchCounter = 0;
if (--HitchCounter < 0)
{
UE_LOG(LogChaosCloth, Warning, TEXT("Hitching for %dms"), ClothSolverDebugHitchLength);
FPlatformProcess::Sleep((float)ClothSolverDebugHitchLength * 0.001f);
HitchCounter = ClothSolverDebugHitchInterval;
}
}
#endif // #if !UE_BUILD_SHIPPING
// Update time step