p.Chaos.Cloth.StiffnessPaddingRatio

p.Chaos.Cloth.StiffnessPaddingRatio

#Overview

name: p.Chaos.Cloth.StiffnessPaddingRatio

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.Cloth.StiffnessPaddingRatio is to control the stiffness padding for the Gauss-Seidel solver in the Chaos cloth simulation system. This setting variable is part of Unreal Engine 5’s physics simulation, specifically for cloth dynamics.

The Chaos physics engine, which is part of Unreal Engine’s experimental features, relies on this setting variable. It is used within the XPBDStretchBiasElementConstraints module, which is responsible for handling stretch and bias constraints in cloth simulation.

The value of this variable is set using a console variable (CVar) system. It is initialized to 0.0f and can be modified at runtime through the console or configuration files.

The associated variable StiffnessPaddingRatio interacts directly with p.Chaos.Cloth.StiffnessPaddingRatio. They share the same value, with StiffnessPaddingRatio being the actual variable used in the code calculations.

Developers must be aware that this variable affects the stiffness calculation in the cloth simulation. Changing its value will impact the behavior of cloth in the game, potentially affecting performance and visual quality.

Best practices when using this variable include:

  1. Experimenting with different values to find the right balance between performance and visual quality.
  2. Documenting any changes made to this variable, as it can significantly impact cloth behavior.
  3. Being cautious when modifying it in a production environment, as it may affect existing cloth setups.

Regarding the associated variable StiffnessPaddingRatio:

The purpose of StiffnessPaddingRatio is to provide a scaling factor for stiffness calculations in the cloth simulation system. It is used directly in the physics calculations for cloth behavior.

This variable is used within the Chaos physics engine, specifically in the XPBDStretchBiasElementConstraints module. It’s part of the core cloth simulation calculations.

The value of StiffnessPaddingRatio is set by the console variable p.Chaos.Cloth.StiffnessPaddingRatio. It’s initialized to 0.0f but can be changed at runtime.

StiffnessPaddingRatio interacts with various other variables in the cloth simulation calculations, particularly in the AddStretchBiasElementResidualAndHessian function.

Developers should be aware that modifying StiffnessPaddingRatio will directly affect the stiffness of cloth in the simulation. It’s a crucial parameter for tuning cloth behavior.

Best practices for using StiffnessPaddingRatio include:

  1. Understanding its impact on cloth physics before making changes.
  2. Testing changes thoroughly in various scenarios to ensure desired cloth behavior.
  3. Considering performance implications when adjusting this value, as it may affect simulation complexity.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/XPBDStretchBiasElementConstraints.cpp:27

Scope (from outer to inner):

file
namespace    Chaos::Softs

Source code excerpt:

	Softs::FSolverReal StiffnessPaddingRatio = 0.f;

	FAutoConsoleVariableRef CVarClothStiffnessPaddingRatio(TEXT("p.Chaos.Cloth.StiffnessPaddingRatio"), StiffnessPaddingRatio, TEXT("stiffness padding for gauss seidel [def: 1]"));

// @todo(chaos): the parallel threshold (or decision to run parallel) should probably be owned by the solver and passed to the constraint container
static int32 Chaos_XPBDStretchBias_ParallelConstraintCount = 100;


 FXPBDStretchBiasElementConstraints::FXPBDStretchBiasElementConstraints(const FSolverParticlesRange& InParticles,

#Associated Variable and Callsites

This variable is associated with another variable named StiffnessPaddingRatio. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/XPBDStretchBiasElementConstraints.cpp:25

Scope (from outer to inner):

file
namespace    Chaos::Softs

Source code excerpt:

namespace Chaos::Softs {

	Softs::FSolverReal StiffnessPaddingRatio = 0.f;

	FAutoConsoleVariableRef CVarClothStiffnessPaddingRatio(TEXT("p.Chaos.Cloth.StiffnessPaddingRatio"), StiffnessPaddingRatio, TEXT("stiffness padding for gauss seidel [def: 1]"));

// @todo(chaos): the parallel threshold (or decision to run parallel) should probably be owned by the solver and passed to the constraint container
static int32 Chaos_XPBDStretchBias_ParallelConstraintCount = 100;


 FXPBDStretchBiasElementConstraints::FXPBDStretchBiasElementConstraints(const FSolverParticlesRange& InParticles,

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/XPBDStretchBiasElementConstraints.cpp:951

Scope (from outer to inner):

file
namespace    Chaos::Softs
function     void FXPBDStretchBiasElementConstraints::InitColor
function     void FXPBDStretchBiasElementConstraints::AddStretchBiasElementResidualAndHessian

Source code excerpt:

	const FSolverVec3 GradCv0 = -GradCv1 - GradCv2;

	const FSolverReal StiffnessScaling = StiffnessPaddingRatio;

	const PMatrix<FSolverReal, 3, 2> DmRest = RestDmArray[ConstraintIndex];
	const FSolverMatrix22 DmMat = DmArray[ConstraintIndex], DmInvMat = DmInverse[ConstraintIndex];
	const PMatrix<FSolverReal, 3, 2> RestUVMatrix = DmRest * DeltaUVInv;
	const FSolverReal RestColumnInnProduct = RestUVMatrix.M[0] * RestUVMatrix.M[3] + RestUVMatrix.M[1] * RestUVMatrix.M[4] + RestUVMatrix.M[2] * RestUVMatrix.M[5];