p.Chaos.PBDCollisionSolver.Position.StaticFriction.Stiffness

p.Chaos.PBDCollisionSolver.Position.StaticFriction.Stiffness

#Overview

name: p.Chaos.PBDCollisionSolver.Position.StaticFriction.Stiffness

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

It is referenced in 9 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.PBDCollisionSolver.Position.StaticFriction.Stiffness is to control the stiffness of static friction in the Position-Based Dynamics (PBD) collision solver within Unreal Engine’s Chaos physics system.

This setting variable is primarily used in the Chaos physics subsystem, specifically in the PBD collision solver module. It’s part of the experimental Chaos physics engine in Unreal Engine 5.

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

The associated variable Chaos_PBDCollisionSolver_Position_StaticFrictionStiffness interacts directly with this console variable. They share the same value, with Chaos_PBDCollisionSolver_Position_StaticFrictionStiffness being the actual variable used in the code.

Developers should be aware that this variable affects the behavior of static friction in collision solving. A higher value will result in stiffer static friction, while a lower value will make it more relaxed. The default value is set to 0.5f, which suggests a balanced approach.

Best practices when using this variable include:

  1. Adjusting it carefully, as it can significantly impact the physics simulation’s behavior.
  2. Testing different values to find the right balance for your specific use case.
  3. Considering performance implications, as higher stiffness values might require more computational resources.

Regarding the associated variable Chaos_PBDCollisionSolver_Position_StaticFrictionStiffness:

This variable is used directly in the physics calculations within the PBD collision solver. It’s applied as a scaling factor to the friction stiffness in both position and velocity solving steps of the collision resolution process.

The variable is used in multiple places:

  1. In the position solving step (SolvePositionWithFriction function) to scale the friction stiffness.
  2. In the velocity solving step (SolveVelocityWithFriction function) to scale the friction stiffness.
  3. It’s also used in SIMD (Single Instruction, Multiple Data) optimized versions of these functions for improved performance.

Developers should be aware that changes to this variable will affect both the position and velocity aspects of the collision solver, potentially impacting the overall feel and stability of physics interactions in the game.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/PBDCollisionSolver.cpp:35

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		FAutoConsoleVariableRef CVarChaos_PBDCollisionSolver_Position_SolveEnabled(TEXT("p.Chaos.PBDCollisionSolver.Position.SolveEnabled"), bChaos_PBDCollisionSolver_Position_SolveEnabled, TEXT(""));
		FAutoConsoleVariableRef CVarChaos_PBDCollisionSolver_Position_MinInvMassScale(TEXT("p.Chaos.PBDCollisionSolver.Position.MinInvMassScale"), Chaos_PBDCollisionSolver_Position_MinInvMassScale, TEXT(""));
		FAutoConsoleVariableRef CVarChaos_PBDCollisionSolver_Position_StaticFrictionStiffness(TEXT("p.Chaos.PBDCollisionSolver.Position.StaticFriction.Stiffness"), Chaos_PBDCollisionSolver_Position_StaticFrictionStiffness, TEXT(""));

		//
		// Velocity Solver Settings
		//

		bool bChaos_PBDCollisionSolver_Velocity_SolveEnabled = true;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/PBDCollisionSolver.cpp:31

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		bool bChaos_PBDCollisionSolver_Position_SolveEnabled = true;
		float Chaos_PBDCollisionSolver_Position_MinInvMassScale = 0.77f;
		float Chaos_PBDCollisionSolver_Position_StaticFrictionStiffness = 0.5f;

		FAutoConsoleVariableRef CVarChaos_PBDCollisionSolver_Position_SolveEnabled(TEXT("p.Chaos.PBDCollisionSolver.Position.SolveEnabled"), bChaos_PBDCollisionSolver_Position_SolveEnabled, TEXT(""));
		FAutoConsoleVariableRef CVarChaos_PBDCollisionSolver_Position_MinInvMassScale(TEXT("p.Chaos.PBDCollisionSolver.Position.MinInvMassScale"), Chaos_PBDCollisionSolver_Position_MinInvMassScale, TEXT(""));
		FAutoConsoleVariableRef CVarChaos_PBDCollisionSolver_Position_StaticFrictionStiffness(TEXT("p.Chaos.PBDCollisionSolver.Position.StaticFriction.Stiffness"), Chaos_PBDCollisionSolver_Position_StaticFrictionStiffness, TEXT(""));

		//
		// Velocity Solver Settings
		//

		bool bChaos_PBDCollisionSolver_Velocity_SolveEnabled = true;

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/PBDCollisionSolverSimd.cpp:19

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

	{
		extern bool bChaos_PBDCollisionSolver_Velocity_FrictionEnabled;
		extern float Chaos_PBDCollisionSolver_Position_StaticFrictionStiffness;
	}

	namespace Private
	{

		//////////////////////////////////////////////////////////////////////////////////////////////////

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/PBDCollisionSolverSimd.cpp:125

Scope (from outer to inner):

file
namespace    Chaos
namespace    Private
function     void FPBDCollisionSolverHelperSimd::SolvePositionWithFriction<4>

Source code excerpt:

		{
			const FSimd4Realf MaxPushOut = FSimd4Realf::Make(InMaxPushOut);
			const FSimd4Realf FrictionStiffnessScale = FSimd4Realf::Make(CVars::Chaos_PBDCollisionSolver_Position_StaticFrictionStiffness);

			for (int32 Index = 0; Index < PrefetchCount; ++Index)
			{
				PrefetchSolvePosition(Index, Solvers, ManifoldPoints, Bodies);
			}

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/PBDCollisionSolverSimd.cpp:181

Scope (from outer to inner):

file
namespace    Chaos
namespace    Private
function     void FPBDCollisionSolverHelperSimd::SolveVelocityWithFriction<4>

Source code excerpt:


			const FSimd4Realf Dt = FSimd4Realf::Make(InDt);
			const FSimd4Realf FrictionStiffnessScale = FSimd4Realf::Make(CVars::Chaos_PBDCollisionSolver_Position_StaticFrictionStiffness);

			for (int32 Index = 0; Index < Solvers.Num(); ++Index)
			{
				PrefetchSolveVelocity(Index + PrefetchCount, Solvers, ManifoldPoints, Bodies);

				Solvers[Index].SolveVelocityWithFriction(ManifoldPoints, Bodies[Index].Body0, Bodies[Index].Body1, Dt, FrictionStiffnessScale);

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Collision/PBDCollisionSolver.h:20

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		extern bool bChaos_PBDCollisionSolver_Velocity_AveragePointEnabled;
		extern bool bChaos_PBDCollisionSolver_Velocity_FrictionEnabled;
		extern float Chaos_PBDCollisionSolver_Position_StaticFrictionStiffness;
		extern float Chaos_PBDCollisionSolver_Velocity_StaticFrictionStiffness;
	}

	namespace Private
	{
		/**

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Collision/PBDCollisionSolver.h:1006

Scope (from outer to inner):

file
namespace    Chaos
namespace    Private
function     void FPBDCollisionSolver::SolvePositionWithFriction

Source code excerpt:


			// Apply the tangential position correction if required
			const FSolverReal FrictionStiffness = State.Stiffness * CVars::Chaos_PBDCollisionSolver_Position_StaticFrictionStiffness;
			if (FrictionStiffness > 0)
			{
				for (int32 PointIndex = 0; PointIndex < NumManifoldPoints(); ++PointIndex)
				{
					FPBDCollisionSolverManifoldPoint& SolverManifoldPoint = State.ManifoldPoints[PointIndex];

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Collision/PBDCollisionSolverJacobi.h:20

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

	{
		extern bool bChaos_PBDCollisionSolver_Velocity_FrictionEnabled;
		extern float Chaos_PBDCollisionSolver_Position_StaticFrictionStiffness;
		extern float Chaos_PBDCollisionSolver_JacobiStiffness;
		extern float Chaos_PBDCollisionSolver_JacobiPositionTolerance;
		extern float Chaos_PBDCollisionSolver_JacobiRotationTolerance;
	}

	namespace Private

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Collision/PBDCollisionSolverJacobi.h:419

Scope (from outer to inner):

file
namespace    Chaos
namespace    Private
class        class FPBDCollisionSolverJacobiManifoldPoints
function     bool SolvePositionWithFriction

Source code excerpt:

					// differences in contacts from tick to tick
					const FSolverReal FrictionMaxPushOut = TotalPushOutNormal / FSolverReal(NumFrictionContacts);
					const FSolverReal FrictionStiffness = Stiffness * CVars::Chaos_PBDCollisionSolver_Position_StaticFrictionStiffness;

					for (int32 ManifoldPointIndex = 0; ManifoldPointIndex < NumManifoldPoints(); ++ManifoldPointIndex)
					{
						if (bApplyFriction[ManifoldPointIndex])
						{
							FSolverReal ContactDeltaTangentU, ContactDeltaTangentV;