p.ChaosCloth.Solver.UseVelocityScale
p.ChaosCloth.Solver.UseVelocityScale
#Overview
name: p.ChaosCloth.Solver.UseVelocityScale
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Use the velocity scale to compensate for clamping to MaxPhysicsDelta, in order to avoid miscalculating velocities during hitches.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.ChaosCloth.Solver.UseVelocityScale is to control the velocity scaling mechanism in the Chaos Cloth simulation solver. It is used to compensate for clamping to MaxPhysicsDelta, which helps avoid miscalculating velocities during hitches (temporary performance drops) in the simulation.
This setting variable is primarily used in the Chaos Cloth system, which is part of Unreal Engine’s physics simulation capabilities. It is specifically utilized in the ChaosCloth plugin, as evident from the file path.
The value of this variable is set through an FAutoConsoleVariableRef, which means it can be adjusted at runtime through console commands or configuration files. It is associated with the C++ boolean variable bClothSolverUseVelocityScale.
This variable interacts closely with other cloth simulation settings, particularly ClothSolverMaxVelocity, which sets the maximum relative velocity of cloth particles. It also has a relationship with the time step and iteration calculations in the solver.
Developers must be aware that enabling this setting (which is the default) will affect the behavior of the cloth simulation, particularly during performance hitches. It may result in more stable and accurate simulations during these periods, but could also potentially mask performance issues.
Best practices when using this variable include:
- Testing the cloth simulation both with and without this setting enabled to understand its impact on your specific use case.
- Monitoring performance and adjusting related settings (like ClothSolverMaxVelocity) in conjunction with this one.
- Being cautious when disabling it, as it may lead to less accurate simulations during performance hitches.
Regarding the associated variable bClothSolverUseVelocityScale:
This is the actual boolean variable that controls the behavior within the C++ code. It is set to true by default, meaning the velocity scaling is enabled out of the box. The variable is used directly in the SetReferenceVelocityScale function of the FClothingSimulationSolver class to determine whether to apply the velocity scale.
Developers should be aware that changing this variable through code will have the same effect as adjusting the console variable. It’s important to ensure consistency between the console variable and any programmatic changes to this boolean to avoid confusion in the cloth simulation behavior.
#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:72
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
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."));
FAutoConsoleVariableRef CVarClothSolverMaxVelocity(TEXT("p.ChaosCloth.Solver.MaxVelocity"), ClothSolverMaxVelocity, TEXT("Maximum relative velocity of the cloth particles relatively to their animated positions equivalent. 0 to disable."));
namespace ClothingSimulationSolverDefault
{
static const Softs::FSolverVec3 Gravity((Softs::FSolverReal)0., (Softs::FSolverReal)0., (Softs::FSolverReal)-980.665); // cm/s^2
static const Softs::FSolverVec3 WindVelocity((Softs::FSolverReal)0.);
#Associated Variable and Callsites
This variable is associated with another variable named bClothSolverUseVelocityScale
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationSolver.cpp:54
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
static bool bClothSolverParallelClothPostUpdate = true;
static bool bClothSolverDisableTimeDependentNumIterations = false;
static bool bClothSolverUseVelocityScale = true;
static float ClothSolverMaxVelocity = 0.f;
#if !UE_BUILD_SHIPPING
static int32 ClothSolverDebugHitchLength = 0;
static int32 ClothSolverDebugHitchInterval = 0;
static bool bClothSolverDisableCollision = false;
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationSolver.cpp:72
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
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."));
FAutoConsoleVariableRef CVarClothSolverMaxVelocity(TEXT("p.ChaosCloth.Solver.MaxVelocity"), ClothSolverMaxVelocity, TEXT("Maximum relative velocity of the cloth particles relatively to their animated positions equivalent. 0 to disable."));
namespace ClothingSimulationSolverDefault
{
static const Softs::FSolverVec3 Gravity((Softs::FSolverReal)0., (Softs::FSolverReal)0., (Softs::FSolverReal)-980.665); // cm/s^2
static const Softs::FSolverVec3 WindVelocity((Softs::FSolverReal)0.);
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationSolver.cpp:1084
Scope (from outer to inner):
file
namespace Chaos
function void FClothingSimulationSolver::SetReferenceVelocityScale
Source code excerpt:
OldRootBoneLocalTransform.AddToTranslation(-OldLocalSpaceLocation);
const FReal SolverVelocityScale = bClothSolverUseVelocityScale ? VelocityScale : (FReal)1.;
// Calculate deltas
const FRigidTransform3 DeltaTransform = ReferenceSpaceTransform.GetRelativeTransform(OldReferenceSpaceTransform);
auto CalculateClampedVelocityScale = [MaxVelocityScale, SolverVelocityScale](FRealSingle InVelocityScale)
{