p.Chaos.Solver.Joint.NumIterationsAtMaxSolverStiffness

p.Chaos.Solver.Joint.NumIterationsAtMaxSolverStiffness

#Overview

name: p.Chaos.Solver.Joint.NumIterationsAtMaxSolverStiffness

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.NumIterationsAtMaxSolverStiffness is to control the number of iterations the Chaos physics solver performs at maximum stiffness when solving joint constraints. This setting is part of the Chaos physics engine, which is Unreal Engine 5’s new physics system.

This setting variable is primarily used by the Chaos physics subsystem, specifically within the PBDRigidsSolver module. It’s an important parameter for fine-tuning the behavior of joint constraints in physics simulations.

The value of this variable is set through the Unreal Engine console variable system. It’s declared as an FAutoConsoleVariableRef, which means it can be adjusted at runtime through console commands or configuration files.

This variable interacts closely with other joint-related settings, particularly ChaosSolverJointMinSolverStiffness and ChaosSolverJointMaxSolverStiffness. These three variables work together to control how the solver stiffness changes over the course of the iterations.

Developers must be aware that this variable directly affects the performance and stability of joint simulations. A higher value will result in more iterations at maximum stiffness, potentially improving stability but at the cost of performance.

Best practices when using this variable include:

  1. Balancing it with MinSolverStiffness and MaxSolverStiffness for optimal results.
  2. Testing thoroughly to find the right balance between simulation stability and performance.
  3. Consider the specific requirements of your game or simulation when adjusting this value.

Regarding the associated variable ChaosSolverJointNumIterationsAtMaxSolverStiffness:

This is the actual integer variable that stores the value set by the console variable. It’s used directly in the physics solver code to control the number of iterations at maximum stiffness.

The value of this variable is set in the PrepareAdvanceBy function of the FPBDRigidsSolver class, where it’s assigned to the NumIterationsAtMaxSolverStiffness field of the JointsSettings structure.

When working with this variable, developers should:

  1. Ensure that any changes to the console variable are reflected in this associated variable.
  2. Be aware that this variable is used directly in the solver calculations, so its value has an immediate impact on physics behavior.
  3. Consider logging or exposing this value for debugging purposes if fine-tuning joint behavior.

#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:394

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		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)."));

		int32 ChaosVisualDebuggerEnable = 1;

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		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)."));

		int32 ChaosVisualDebuggerEnable = 1;

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

Scope (from outer to inner):

file
namespace    Chaos
function     void FPBDRigidsSolver::PrepareAdvanceBy

Source code excerpt:

		JointsSettings.MinSolverStiffness = ChaosSolverJointMinSolverStiffness;
		JointsSettings.MaxSolverStiffness = ChaosSolverJointMaxSolverStiffness;
		JointsSettings.NumIterationsAtMaxSolverStiffness = ChaosSolverJointNumIterationsAtMaxSolverStiffness;
		JointsSettings.PositionTolerance = ChaosSolverJointPositionTolerance;
		JointsSettings.AngleTolerance = ChaosSolverJointAngleTolerance;
		JointsSettings.MinParentMassRatio = ChaosSolverJointMinParentMassRatio;
		JointsSettings.MaxInertiaRatio = ChaosSolverJointMaxInertiaRatio;
		JointsSettings.bSolvePositionLast = bChaosSolverJointSolvePositionLast;
		JointsSettings.bUsePositionBasedDrives = bChaosSolverJointUsePositionBasedDrives;