p.Chaos.PBDCollisionSolver.Position.MinInvMassScale

p.Chaos.PBDCollisionSolver.Position.MinInvMassScale

#Overview

name: p.Chaos.PBDCollisionSolver.Position.MinInvMassScale

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

It is referenced in 8 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.PBDCollisionSolver.Position.MinInvMassScale is to control the minimum inverse mass scale used in the Position-Based Dynamics (PBD) collision solver for Unreal Engine’s Chaos physics system. This setting variable is specifically used for position-based collision resolution and shock propagation in the physics simulation.

This setting variable is primarily used by the Chaos physics subsystem, which is part of Unreal Engine’s experimental physics framework. It is utilized in the PBD collision solver module, which handles collision detection and resolution for physical objects in the game world.

The value of this variable is set in the C++ code, with a default value of 0.77f. It can be modified at runtime through the console variable system, allowing developers to fine-tune the physics behavior without recompiling the engine.

The associated variable Chaos_PBDCollisionSolver_Position_MinInvMassScale directly interacts with p.Chaos.PBDCollisionSolver.Position.MinInvMassScale, as they share the same value. This associated variable is used in various parts of the collision solver code to apply the minimum inverse mass scale during calculations.

Developers should be aware that this variable affects the behavior of collision resolution, particularly in scenarios involving objects with significantly different masses. It helps prevent numerical instabilities and improves the overall stability of the physics simulation.

Best practices when using this variable include:

  1. Experimenting with different values to find the optimal balance between simulation stability and physical accuracy for your specific game scenarios.
  2. Monitoring performance impacts when adjusting this value, as it can affect the computational cost of the physics simulation.
  3. Considering the interplay between this variable and other physics settings, such as the velocity solver settings and iteration counts.

Regarding the associated variable Chaos_PBDCollisionSolver_Position_MinInvMassScale:

The purpose of this variable is to store and provide access to the minimum inverse mass scale value within the Chaos physics code. It is used in various parts of the collision solver implementation to apply the shock propagation effect and adjust the solver’s behavior based on object masses.

This variable is used in both the position and velocity solvers of the PBD collision system. It’s particularly important in the shock propagation calculations, which help to stabilize the simulation when dealing with collisions between objects of very different masses.

The value of this variable is set to match p.Chaos.PBDCollisionSolver.Position.MinInvMassScale, allowing for easy access and modification through the console variable system.

Developers should be aware that changes to this variable will affect both position and velocity solvers in the PBD collision system. It’s crucial to test thoroughly after making adjustments to ensure the desired physics behavior is achieved across all scenarios in your 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:34

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
		//

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		extern bool bChaos_PBDCollisionSolver_Position_SolveEnabled;
		extern bool bChaos_PBDCollisionSolver_Velocity_SolveEnabled;
		extern float Chaos_PBDCollisionSolver_Position_MinInvMassScale;
		extern float Chaos_PBDCollisionSolver_Velocity_MinInvMassScale;

		// If one body is more than MassRatio1 times the mass of the other, adjust the solver stiffness when the lighter body is underneath.
		// Solver stiffness will be equal to 1 when the mass ratio is MassRatio1.
		// Solver stiffness will be equal to 0 when the mass ratio is MassRatio2.
		FRealSingle Chaos_PBDCollisionSolver_AutoStiffness_MassRatio1 = 0;

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

Scope (from outer to inner):

file
namespace    Chaos
function     void FPBDCollisionContainerSolver::UpdatePositionShockPropagation

Source code excerpt:

	{
		const bool bEnableShockPropagation = (It >= NumIts - SolverSettings.NumPositionShockPropagationIterations);
		const FSolverReal ShockPropagation = (bEnableShockPropagation) ? CVars::Chaos_PBDCollisionSolver_Position_MinInvMassScale : FSolverReal(1);
		ApplyShockPropagation(ShockPropagation);
	}

	void FPBDCollisionContainerSolver::UpdateVelocityShockPropagation(const FReal Dt, const int32 It, const int32 NumIts, const int32 BeginIndex, const int32 EndIndex, const FPBDCollisionSolverSettings& SolverSettings)
	{
		const bool bEnableShockPropagation = (It >= NumIts - SolverSettings.NumVelocityShockPropagationIterations);

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    Private
function     void FPBDCollisionContainerSolverSimd::UpdatePositionShockPropagation

Source code excerpt:

		{
			const bool bEnableShockPropagation = (It >= NumIts - SolverSettings.NumPositionShockPropagationIterations);
			const FSolverReal ShockPropagation = (bEnableShockPropagation) ? CVars::Chaos_PBDCollisionSolver_Position_MinInvMassScale : FSolverReal(1);
			ApplyShockPropagation(ShockPropagation);
		}

		void FPBDCollisionContainerSolverSimd::UpdateVelocityShockPropagation(const int32 It, const int32 NumIts, const FPBDCollisionSolverSettings& SolverSettings)
		{
			const bool bEnableShockPropagation = (It >= NumIts - SolverSettings.NumVelocityShockPropagationIterations);

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

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;
		// If Chaos_PBDCollisionSolver_Velocity_MinInvMassScale is the same as Chaos_PBDCollisionSolver_Position_MinInvMassScale and all velocity iterations have shockpropagation, we avoid recalculating constraint-space mass
		float Chaos_PBDCollisionSolver_Velocity_MinInvMassScale = Chaos_PBDCollisionSolver_Position_MinInvMassScale;
		bool bChaos_PBDCollisionSolver_Velocity_FrictionEnabled = true;
		float Chaos_PBDCollisionSolver_Velocity_StaticFrictionStiffness = 1.0f;
		bool bChaos_PBDCollisionSolver_Velocity_AveragePointEnabled = false;

		FAutoConsoleVariableRef CVarChaos_PBDCollisionSolver_Velocity_SolveEnabled(TEXT("p.Chaos.PBDCollisionSolver.Velocity.SolveEnabled"), bChaos_PBDCollisionSolver_Velocity_SolveEnabled, TEXT(""));
		FAutoConsoleVariableRef CVarChaos_PBDCollisionSolver_Velocity_MinInvMassScale(TEXT("p.Chaos.PBDCollisionSolver.Velocity.MinInvMassScale"), Chaos_PBDCollisionSolver_Velocity_MinInvMassScale, TEXT(""));

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

	namespace CVars
	{
		extern float Chaos_PBDCollisionSolver_Position_MinInvMassScale;
		extern float Chaos_PBDCollisionSolver_Velocity_MinInvMassScale;
	}

	namespace Private
	{
		//////////////////////////////////////////////////////////////////////////////////////////////////

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    Private
function     void FPBDCollisionSolverJacobi::EnablePositionShockPropagation

Source code excerpt:

		void FPBDCollisionSolverJacobi::EnablePositionShockPropagation()
		{
			SetShockPropagationInvMassScale(CVars::Chaos_PBDCollisionSolver_Position_MinInvMassScale);
		}

		void FPBDCollisionSolverJacobi::EnableVelocityShockPropagation()
		{
			SetShockPropagationInvMassScale(CVars::Chaos_PBDCollisionSolver_Velocity_MinInvMassScale);
		}

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

	namespace CVars
	{
		extern float Chaos_PBDCollisionSolver_Position_MinInvMassScale;
		extern float Chaos_PBDCollisionSolver_Velocity_MinInvMassScale;
	}

	namespace Private
	{
		template<int TNumLanes>