p.Chaos.Solver.Joint.UseLinearSolver

p.Chaos.Solver.Joint.UseLinearSolver

#Overview

name: p.Chaos.Solver.Joint.UseLinearSolver

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.UseLinearSolver is to control whether the Chaos physics solver in Unreal Engine 5 uses a linear version of the joint solver or not. This setting is part of the physics simulation system, specifically the joint constraint solving mechanism within the Chaos solver.

This setting variable is primarily used by the Chaos physics subsystem, which is part of the Experimental namespace in Unreal Engine 5. It’s utilized within the PBDRigidsSolver (Position Based Dynamics Rigids Solver) module.

The value of this variable is set through an FAutoConsoleVariableRef, which means it can be modified at runtime through console commands. The default value is set to true, enabling the linear version of the joint solver by default.

The associated variable bChaosSolverJointUseLinearSolver directly interacts with p.Chaos.Solver.Joint.UseLinearSolver. They share the same value, with bChaosSolverJointUseLinearSolver being the C++ variable that’s used within the code to actually apply the setting.

Developers should be aware that changing this variable will affect the behavior of joint constraints in the physics simulation. The linear solver is likely more performant but may be less accurate in certain scenarios compared to a non-linear solver.

Best practices when using this variable include:

  1. Testing the impact of both true and false values on your specific use case, as performance and accuracy needs may vary.
  2. Considering the trade-off between performance and accuracy based on the requirements of your project.
  3. Being cautious when changing this value at runtime, as it could lead to sudden changes in physics behavior.

Regarding the associated variable bChaosSolverJointUseLinearSolver:

The purpose of bChaosSolverJointUseLinearSolver is to directly control the joint solver mode within the Chaos physics system. It’s the C++ representation of the console variable p.Chaos.Solver.Joint.UseLinearSolver.

This variable is used within the Chaos physics subsystem, specifically in the PBDRigidsSolver class.

The value of this variable is set initially to true and can be modified through the associated console variable.

It interacts directly with p.Chaos.Solver.Joint.UseLinearSolver, and its value is used to set the bUseLinearSolver property of the JointsSettings structure in the PrepareAdvanceBy function of FPBDRigidsSolver.

Developers should be aware that this variable directly affects the behavior of the physics solver. Changing it will impact how joint constraints are resolved in the simulation.

Best practices include:

  1. Ensuring consistency between this variable and the console variable if modifying it programmatically.
  2. Considering the impact on both performance and simulation accuracy when changing this value.
  3. Testing thoroughly with both true and false values to understand the impact on your specific physics scenarios.

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		// Joint solver mode (linear vs non-linear)
		bool bChaosSolverJointUseLinearSolver = true;
		FAutoConsoleVariableRef CVarChaosSolverJointUseCachedSolver(TEXT("p.Chaos.Solver.Joint.UseLinearSolver"), bChaosSolverJointUseLinearSolver, TEXT("Use linear version of joint solver. (default is true"));

		// Enable/Disable collisions
		bool bChaosSolverCollisionEnabled = true;
		FAutoConsoleVariableRef CVarChaosSolverCollisionDisable(TEXT("p.Chaos.Solver.Collision.Enabled"), bChaosSolverCollisionEnabled, TEXT("Enable/Disable collisions in the main scene."));

		// Shrink particle arrays every frame to recove rmemory when a scene changes significantly

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:


		// Joint solver mode (linear vs non-linear)
		bool bChaosSolverJointUseLinearSolver = true;
		FAutoConsoleVariableRef CVarChaosSolverJointUseCachedSolver(TEXT("p.Chaos.Solver.Joint.UseLinearSolver"), bChaosSolverJointUseLinearSolver, TEXT("Use linear version of joint solver. (default is true"));

		// Enable/Disable collisions
		bool bChaosSolverCollisionEnabled = true;
		FAutoConsoleVariableRef CVarChaosSolverCollisionDisable(TEXT("p.Chaos.Solver.Collision.Enabled"), bChaosSolverCollisionEnabled, TEXT("Enable/Disable collisions in the main scene."));

		// Shrink particle arrays every frame to recove rmemory when a scene changes significantly

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

Scope (from outer to inner):

file
namespace    Chaos
function     void FPBDRigidsSolver::PrepareAdvanceBy

Source code excerpt:

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

		// Apply CVAR overrides if set
		{
			// To enable runtime support for switching collision features on/off we need to update existing constraints when config changes.