p.ChaosCloth.Solver.MaxVelocity
p.ChaosCloth.Solver.MaxVelocity
#Overview
name: p.ChaosCloth.Solver.MaxVelocity
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Maximum relative velocity of the cloth particles relatively to their animated positions equivalent. 0 to disable.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.ChaosCloth.Solver.MaxVelocity is to set the maximum relative velocity of cloth particles in relation to their animated positions in the Chaos Cloth simulation system. This setting is part of Unreal Engine 5’s cloth simulation functionality, specifically within the Chaos physics system.
This setting variable is primarily used in the ChaosCloth plugin, which is part of Unreal Engine’s physics and simulation subsystem. It’s specifically utilized in the cloth simulation solver module.
The value of this variable is set through a console variable (CVar) system, as seen in the code where it’s defined using FAutoConsoleVariableRef. This allows developers to modify the value at runtime or through configuration files.
The p.ChaosCloth.Solver.MaxVelocity variable interacts directly with its associated variable ClothSolverMaxVelocity. They share the same value, with the console variable acting as an interface to set the internal ClothSolverMaxVelocity variable.
Developers should be aware that:
- Setting this value to 0 disables the maximum velocity constraint.
- The value is used to calculate a maximum velocity squared value, which is then used in the simulation.
- It affects the behavior of cloth particles during simulation, potentially limiting their movement speed.
Best practices when using this variable include:
- Adjust the value based on the scale and speed of your game world to achieve realistic cloth behavior.
- Use it to prevent cloth from moving unrealistically fast during sudden movements or collisions.
- Monitor performance impact when adjusting this value, as it may affect simulation complexity.
Regarding the associated variable ClothSolverMaxVelocity:
- It’s the internal representation of the maximum velocity value used in the actual simulation calculations.
- It’s initialized as a static float with a default value of 0.f.
- It’s used in the ApplyPreSimulationTransforms function to calculate the maximum allowed velocity squared for cloth particles.
- Developers should not modify this variable directly, but instead use the p.ChaosCloth.Solver.MaxVelocity console variable to ensure proper synchronization between the two.
#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:73
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.);
static const int32 NumIterations = 1;
#Associated Variable and Callsites
This variable is associated with another variable named ClothSolverMaxVelocity
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationSolver.cpp:55
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
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:73
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.);
static const int32 NumIterations = 1;
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationSolver.cpp:1496
Scope (from outer to inner):
file
namespace Chaos
function void FClothingSimulationSolver::ApplyPreSimulationTransforms
Source code excerpt:
const Softs::FSolverVec3 DeltaLocalSpaceLocation(LocalSpaceLocation - OldLocalSpaceLocation); // LWC, note that LocalSpaceLocation is FReal based. but the delta can be stored in FSolverReal
const FSolverReal MaxVelocitySquared = (ClothSolverMaxVelocity > 0.f) ? FMath::Square((FSolverReal)ClothSolverMaxVelocity) : TNumericLimits<FSolverReal>::Max();
if (Evolution)
{
const TArray<uint32> ActiveGroups = Evolution->GetActiveGroups().Array();
PhysicsParallelFor(ActiveGroups.Num(), [this, &ActiveGroups, &DeltaLocalSpaceLocation, MaxVelocitySquared](int32 ActiveGroupIndex)
{