p.ChaosCloth.GravityMultiplier
p.ChaosCloth.GravityMultiplier
#Overview
name: p.ChaosCloth.GravityMultiplier
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Scalar multiplier applied at the final stage of the cloth\'s gravity formulation.
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.ChaosCloth.GravityMultiplier is to provide a scalar multiplier for the cloth’s gravity calculation in Unreal Engine 5’s Chaos Cloth simulation system. This setting variable is used to adjust the strength of gravity applied to cloth simulations.
This setting variable is primarily used in the Chaos Cloth plugin, which is part of Unreal Engine 5’s physics simulation system. Specifically, it’s utilized in the ClothingSimulationCloth module.
The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1.0f, but can be changed at runtime through console commands or programmatically.
The p.ChaosCloth.GravityMultiplier interacts directly with the associated variable CVarGravityMultiplier. They share the same value and are used interchangeably in the code.
Developers must be aware that this variable affects the final stage of the cloth’s gravity formulation. Changing this value will directly impact how gravity influences cloth simulations in the game.
Best practices when using this variable include:
- Use it to fine-tune the gravity effect on cloth simulations without changing the overall world gravity.
- Be cautious when modifying this value, as extreme values may lead to unrealistic cloth behavior.
- Consider using this in conjunction with other cloth simulation parameters for best results.
Regarding the associated variable CVarGravityMultiplier:
The purpose of CVarGravityMultiplier is to provide programmatic access to the p.ChaosCloth.GravityMultiplier value within the C++ code of the Chaos Cloth system.
This variable is used in the Chaos Cloth plugin, specifically in the ClothingSimulationCloth and ClothConstraints modules.
The value of CVarGravityMultiplier is set automatically by the console variable system when p.ChaosCloth.GravityMultiplier is modified.
CVarGravityMultiplier interacts directly with the ExternalForces object in the cloth simulation, setting the world gravity multiplier.
Developers should be aware that this variable is used in performance-critical sections of the cloth simulation code, so frequent changes to its value could potentially impact performance.
Best practices for using CVarGravityMultiplier include:
- Use GetValueOnAnyThread() when accessing its value to ensure thread-safe operations.
- Consider caching the value if it’s used frequently in performance-critical code sections.
- Remember that changes to this variable will affect all cloth simulations using the Chaos Cloth system.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationCloth.cpp:49
Scope (from outer to inner):
file
namespace Chaos
namespace ClothingSimulationClothConsoleVariables
Source code excerpt:
TAutoConsoleVariable<float> CVarGravityMultiplier(
TEXT("p.ChaosCloth.GravityMultiplier"),
1.f,
TEXT("Scalar multiplier applied at the final stage of the cloth's gravity formulation."));
}
using namespace Softs;
struct FClothingSimulationCloth::FLODData
#Associated Variable and Callsites
This variable is associated with another variable named CVarGravityMultiplier
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothConstraints.cpp:39
Scope (from outer to inner):
file
namespace Chaos
namespace ClothingSimulationClothConsoleVariables
Source code excerpt:
// These are defined in ChaosClothingSimulationCloth.cpp
extern TAutoConsoleVariable<bool> CVarLegacyDisablesAccurateWind;
extern TAutoConsoleVariable<float> CVarGravityMultiplier;
}
bool bEnableGS = false;
#if !UE_BUILD_SHIPPING
static FAutoConsoleVariableRef CVarClothbEnableGS(TEXT("p.Chaos.Cloth.EnableGaussSeidel"), bEnableGS, TEXT("Use Gauss Seidel constraints instead of XPBD [def: false]"));
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothConstraints.cpp:2201
Scope (from outer to inner):
file
namespace Chaos
function void FClothConstraints::UpdateFromSolver
Source code excerpt:
if (ExternalForces)
{
ExternalForces->SetWorldGravityMultiplier((FSolverReal)ClothingSimulationClothConsoleVariables::CVarGravityMultiplier.GetValueOnAnyThread());
ExternalForces->SetSolverGravityProperties(SolverGravity, bPerClothGravityOverrideEnabled);
ExternalForces->SetFictitiousForcesData(FictitiousAngularVelocity, ReferenceSpaceLocation);
ExternalForces->SetSolverWind(InSolverWindVelocity, LegacyWindAdaptation);
}
SolverWindVelocity = InSolverWindVelocity;
}
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationCloth.cpp:48
Scope (from outer to inner):
file
namespace Chaos
namespace ClothingSimulationClothConsoleVariables
Source code excerpt:
TEXT("Whether using the Legacy wind model switches off the accurate wind model, or adds up to it"));
TAutoConsoleVariable<float> CVarGravityMultiplier(
TEXT("p.ChaosCloth.GravityMultiplier"),
1.f,
TEXT("Scalar multiplier applied at the final stage of the cloth's gravity formulation."));
}
using namespace Softs;
#Loc: <Workspace>/Engine/Plugins/ChaosCloth/Source/ChaosCloth/Private/ChaosCloth/ChaosClothingSimulationCloth.cpp:905
Scope (from outer to inner):
file
namespace Chaos
function TVec3<FRealSingle> FClothingSimulationCloth::GetGravity
Source code excerpt:
const TVec3<FRealSingle> GravityOverride = (TVec3<FRealSingle>)ConfigProperties.GetValue<FVector3f>(TEXT("GravityOverride"), FVector3f(0.f, 0.f, ClothingSimulationClothDefault::GravityZOverride));
const FRealSingle GravityScale = (FRealSingle)ConfigProperties.GetValue<float>(TEXT("GravityScale"), 1.f);
const FRealSingle GravityMultiplier = (FRealSingle)ClothingSimulationClothConsoleVariables::CVarGravityMultiplier.GetValueOnAnyThread();
return (Solver->IsClothGravityOverrideEnabled() && bUseGravityOverride ? GravityOverride : Solver->GetGravity() * GravityScale) * GravityMultiplier;
}
}
FAABB3 FClothingSimulationCloth::CalculateBoundingBox(const FClothingSimulationSolver* Solver) const