p.Chaos.Solver.Joint.MaxSolverStiffness

p.Chaos.Solver.Joint.MaxSolverStiffness

#Overview

name: p.Chaos.Solver.Joint.MaxSolverStiffness

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.Solver.Joint.MaxSolverStiffness is to control the maximum solver stiffness for joint constraints in Unreal Engine’s Chaos physics system. This setting is specifically used in the joint solver, which is part of the physics simulation subsystem.

This variable is primarily used in the Chaos physics module, which is part of Unreal Engine’s experimental physics system. It’s referenced in the PBDRigidsSolver, which is responsible for solving rigid body dynamics using Position Based Dynamics (PBD).

The value of this variable is set through a console variable (CVar) system, which allows for runtime modification. It’s initialized with a default value of 1.0f and can be changed during runtime or through configuration files.

This variable interacts closely with p.Chaos.Solver.Joint.MinSolverStiffness. Together, they define a range of solver stiffness that is applied over the course of the solver’s iterations. The solver starts with the minimum stiffness and increases it towards the maximum stiffness with each iteration.

Developers should be aware that this variable directly affects the behavior of joint constraints in the physics simulation. Higher values will make joints more rigid, while lower values will allow for more flexibility. The optimal value can depend on the specific requirements of the simulation and the types of joints being used.

Best practices when using this variable include:

  1. Balancing it with MinSolverStiffness to achieve the desired joint behavior.
  2. Considering the performance impact of higher stiffness values, which may require more iterations to solve.
  3. Testing different values to find the right balance between stability and performance for your specific use case.

Regarding the associated variable ChaosSolverJointMaxSolverStiffness:

This is the actual float variable that stores the value set by the p.Chaos.Solver.Joint.MaxSolverStiffness CVar. It’s used directly in the solver code to apply the maximum stiffness to joint constraints.

The value of ChaosSolverJointMaxSolverStiffness is set through the CVar system and is then used in the PrepareAdvanceBy function of the FPBDRigidsSolver class to configure the joint solver settings before each physics step.

When working with this variable, developers should:

  1. Understand that changes to the CVar will be reflected in this variable.
  2. Be aware that this value is used directly in the physics calculations, so extreme values could lead to instability or unrealistic behavior.
  3. Consider logging or exposing this value for debugging purposes if joint behavior seems unexpected.

In summary, both p.Chaos.Solver.Joint.MaxSolverStiffness and ChaosSolverJointMaxSolverStiffness work together to control the maximum stiffness of joint constraints in the Chaos physics system, allowing developers to fine-tune the behavior of jointed objects in their simulations.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:393

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		FRealSingle ChaosSolverJointShockPropagation = -1.0f;
		FAutoConsoleVariableRef CVarChaosSolverJointMinSolverStiffness(TEXT("p.Chaos.Solver.Joint.MinSolverStiffness"), ChaosSolverJointMinSolverStiffness, TEXT("Solver stiffness on first iteration, increases each iteration toward MaxSolverStiffness."));
		FAutoConsoleVariableRef CVarChaosSolverJointMaxSolverStiffness(TEXT("p.Chaos.Solver.Joint.MaxSolverStiffness"), ChaosSolverJointMaxSolverStiffness, TEXT("Solver stiffness on last iteration, increases each iteration from MinSolverStiffness."));
		FAutoConsoleVariableRef CVarChaosSolverJointNumIterationsAtMaxSolverStiffness(TEXT("p.Chaos.Solver.Joint.NumIterationsAtMaxSolverStiffness"), ChaosSolverJointNumIterationsAtMaxSolverStiffness, TEXT("How many iterations we want at MaxSolverStiffness."));
		FAutoConsoleVariableRef CVarChaosSolverJointSolvePositionFirst(TEXT("p.Chaos.Solver.Joint.SolvePositionLast"), bChaosSolverJointSolvePositionLast, TEXT("Should we solve joints in position-then-rotation order (false) or rotation-then-position order (true, default)"));
		FAutoConsoleVariableRef CVarChaosSolverJointUsePBDVelocityDrives(TEXT("p.Chaos.Solver.Joint.UsePBDDrives"), bChaosSolverJointUsePositionBasedDrives, TEXT("Whether to solve drives in the position or velocity phase of the solver (default true"));
		FAutoConsoleVariableRef CVarChaosSolverJointNumShockPropagationIterations(TEXT("p.Chaos.Solver.Joint.NumShockPropagationIterations"), ChaosSolverJointNumShockProagationIterations, TEXT("How many iterations to enable SHockProagation for."));
		FAutoConsoleVariableRef CVarChaosSolverJointShockPropagation(TEXT("p.Chaos.Solver.Joint.ShockPropagation"), ChaosSolverJointShockPropagation, TEXT("6Dof joint shock propagation override (if >= 0)."));

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:386

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		// Joint cvars
		float ChaosSolverJointMinSolverStiffness = 1.0f;
		float ChaosSolverJointMaxSolverStiffness = 1.0f;
		int32 ChaosSolverJointNumIterationsAtMaxSolverStiffness = 1;
		bool bChaosSolverJointSolvePositionLast = true;
		bool bChaosSolverJointUsePositionBasedDrives = true;
		int32 ChaosSolverJointNumShockProagationIterations = 0;
		FRealSingle ChaosSolverJointShockPropagation = -1.0f;
		FAutoConsoleVariableRef CVarChaosSolverJointMinSolverStiffness(TEXT("p.Chaos.Solver.Joint.MinSolverStiffness"), ChaosSolverJointMinSolverStiffness, TEXT("Solver stiffness on first iteration, increases each iteration toward MaxSolverStiffness."));
		FAutoConsoleVariableRef CVarChaosSolverJointMaxSolverStiffness(TEXT("p.Chaos.Solver.Joint.MaxSolverStiffness"), ChaosSolverJointMaxSolverStiffness, TEXT("Solver stiffness on last iteration, increases each iteration from MinSolverStiffness."));
		FAutoConsoleVariableRef CVarChaosSolverJointNumIterationsAtMaxSolverStiffness(TEXT("p.Chaos.Solver.Joint.NumIterationsAtMaxSolverStiffness"), ChaosSolverJointNumIterationsAtMaxSolverStiffness, TEXT("How many iterations we want at MaxSolverStiffness."));
		FAutoConsoleVariableRef CVarChaosSolverJointSolvePositionFirst(TEXT("p.Chaos.Solver.Joint.SolvePositionLast"), bChaosSolverJointSolvePositionLast, TEXT("Should we solve joints in position-then-rotation order (false) or rotation-then-position order (true, default)"));
		FAutoConsoleVariableRef CVarChaosSolverJointUsePBDVelocityDrives(TEXT("p.Chaos.Solver.Joint.UsePBDDrives"), bChaosSolverJointUsePositionBasedDrives, TEXT("Whether to solve drives in the position or velocity phase of the solver (default true"));
		FAutoConsoleVariableRef CVarChaosSolverJointNumShockPropagationIterations(TEXT("p.Chaos.Solver.Joint.NumShockPropagationIterations"), ChaosSolverJointNumShockProagationIterations, TEXT("How many iterations to enable SHockProagation for."));
		FAutoConsoleVariableRef CVarChaosSolverJointShockPropagation(TEXT("p.Chaos.Solver.Joint.ShockPropagation"), ChaosSolverJointShockPropagation, TEXT("6Dof joint shock propagation override (if >= 0)."));

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:1293

Scope (from outer to inner):

file
namespace    Chaos
function     void FPBDRigidsSolver::PrepareAdvanceBy

Source code excerpt:

		FPBDJointSolverSettings JointsSettings = MEvolution->GetJointConstraints().GetSettings();
		JointsSettings.MinSolverStiffness = ChaosSolverJointMinSolverStiffness;
		JointsSettings.MaxSolverStiffness = ChaosSolverJointMaxSolverStiffness;
		JointsSettings.NumIterationsAtMaxSolverStiffness = ChaosSolverJointNumIterationsAtMaxSolverStiffness;
		JointsSettings.PositionTolerance = ChaosSolverJointPositionTolerance;
		JointsSettings.AngleTolerance = ChaosSolverJointAngleTolerance;
		JointsSettings.MinParentMassRatio = ChaosSolverJointMinParentMassRatio;
		JointsSettings.MaxInertiaRatio = ChaosSolverJointMaxInertiaRatio;
		JointsSettings.bSolvePositionLast = bChaosSolverJointSolvePositionLast;