p.Chaos.Solver.Joint.NumShockPropagationIterations

p.Chaos.Solver.Joint.NumShockPropagationIterations

#Overview

name: p.Chaos.Solver.Joint.NumShockPropagationIterations

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.NumShockPropagationIterations is to control the number of iterations for shock propagation in the joint solver of Unreal Engine’s Chaos physics system. This setting is part of the physics simulation, specifically related to joint constraints and their behavior during collisions or sudden forces.

This setting variable is primarily used by the Chaos physics system, which is an experimental physics solver in Unreal Engine 5. It’s part of the joint solver subsystem within the Chaos module.

The value of this variable is set through a console variable (CVAR) system. It’s defined and initialized in the Chaos namespace, specifically in the CVars section of the PBDRigidsSolver.cpp file.

The associated variable ChaosSolverJointNumShockProagationIterations interacts directly with p.Chaos.Solver.Joint.NumShockPropagationIterations. They share the same value, with the console variable acting as an interface for runtime modification.

Developers should be aware that this variable affects the performance and accuracy of joint simulations in physics-heavy scenes. A higher number of iterations may lead to more accurate simulations but at the cost of performance.

Best practices when using this variable include:

  1. Start with the default value and adjust only if necessary.
  2. Monitor performance impact when increasing the number of iterations.
  3. Use in conjunction with other joint-related settings for optimal results.
  4. Consider the trade-off between simulation accuracy and performance based on your project’s needs.

Regarding the associated variable ChaosSolverJointNumShockProagationIterations:

This variable is an internal representation of the console variable. It’s used within the Chaos solver to actually implement the number of shock propagation iterations. It’s initialized in the same file and is set to 0 by default.

The value of ChaosSolverJointNumShockProagationIterations is applied in the PrepareAdvanceBy function of the FPBDRigidsSolver class. This function prepares the solver for the next physics step, applying various settings including the number of shock propagation iterations.

Developers should note that modifying ChaosSolverJointNumShockProagationIterations directly in code will have the same effect as changing the console variable, but won’t persist between sessions unless saved to configuration files.

When working with this variable, it’s important to consider its impact on the overall joint simulation behavior and to test thoroughly in scenarios that stress the physics system, particularly those involving complex joint setups or high-impact collisions.

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		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;
		FAutoConsoleVariableRef CVarChaosVisualDebuggerEnable(TEXT("p.Chaos.VisualDebuggerEnable"), ChaosVisualDebuggerEnable, TEXT("Enable/Disable pushing/saving data to the visual debugger"));

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		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;
		FAutoConsoleVariableRef CVarChaosVisualDebuggerEnable(TEXT("p.Chaos.VisualDebuggerEnable"), ChaosVisualDebuggerEnable, TEXT("Enable/Disable pushing/saving data to the visual debugger"));

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

Scope (from outer to inner):

file
namespace    Chaos
function     void FPBDRigidsSolver::PrepareAdvanceBy

Source code excerpt:

		JointsSettings.bSolvePositionLast = bChaosSolverJointSolvePositionLast;
		JointsSettings.bUsePositionBasedDrives = bChaosSolverJointUsePositionBasedDrives;
		JointsSettings.NumShockPropagationIterations = ChaosSolverJointNumShockProagationIterations;
		JointsSettings.ShockPropagationOverride = ChaosSolverJointShockPropagation;
		JointsSettings.bUseLinearSolver = bChaosSolverJointUseLinearSolver;
		JointsSettings.bSortEnabled = false;
		MEvolution->GetJointConstraints().SetSettings(JointsSettings);

		// Apply CVAR overrides if set