p.Chaos.PBDCollisionSolver.Velocity.MinInvMassScale

p.Chaos.PBDCollisionSolver.Velocity.MinInvMassScale

#Overview

name: p.Chaos.PBDCollisionSolver.Velocity.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.Velocity.MinInvMassScale is to control the minimum inverse mass scale used in the Position-Based Dynamics (PBD) collision solver for velocity calculations within Unreal Engine’s Chaos physics system.

This setting variable is primarily used by the Chaos physics engine, specifically within the PBD collision solver module. It’s part of the experimental Chaos namespace, indicating it’s a feature of the newer Chaos physics system in Unreal Engine.

The value of this variable is set through a console variable (CVar) system, allowing it to be adjusted at runtime. It’s initialized in the Chaos::CVars namespace and can be modified using the console command “p.Chaos.PBDCollisionSolver.Velocity.MinInvMassScale”.

This variable interacts closely with Chaos_PBDCollisionSolver_Velocity_MinInvMassScale, which shares the same value. It’s also related to Chaos_PBDCollisionSolver_Position_MinInvMassScale, as they are often used in conjunction for shock propagation calculations.

Developers should be aware that this variable affects the behavior of collision solving, particularly in how it handles mass ratios between colliding bodies. It’s used in shock propagation calculations, which can impact the stability and realism of physics simulations, especially when dealing with objects of vastly different masses.

Best practices when using this variable include:

  1. Carefully tuning its value to balance between simulation stability and physical accuracy.
  2. Testing thoroughly with various mass ratios to ensure desired behavior across different scenarios.
  3. Considering its interaction with related variables, particularly the position-based counterpart.

Regarding the associated variable Chaos_PBDCollisionSolver_Velocity_MinInvMassScale:

This variable is the internal representation of the console variable. It’s used directly in the collision solving code to apply shock propagation and adjust solver stiffness based on mass ratios. It’s particularly important in the UpdateVelocityShockPropagation functions of both the regular and SIMD versions of the PBDCollisionContainerSolver.

The variable is initialized to the same value as Chaos_PBDCollisionSolver_Position_MinInvMassScale, which allows for optimization in certain scenarios where recalculating constraint-space mass can be avoided.

Developers should be aware that changes to this variable will directly affect the physics simulation’s behavior, particularly in how it handles collisions between objects with significant mass differences. It’s a key parameter in fine-tuning the balance between simulation stability and physical accuracy in the Chaos physics system.

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:


		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(""));
		FAutoConsoleVariableRef CVarChaos_PBDCollisionSolver_Velocity_FrictionEnabled(TEXT("p.Chaos.PBDCollisionSolver.Velocity.FrictionEnabled"), bChaos_PBDCollisionSolver_Velocity_FrictionEnabled, TEXT(""));
		FAutoConsoleVariableRef CVarChaos_PBDCollisionSolver_Velocity_StaticFrictionStiffness(TEXT("p.Chaos.PBDCollisionSolver.Velocity.StaticFriction.Stiffness"), Chaos_PBDCollisionSolver_Velocity_StaticFrictionStiffness, TEXT(""));
		FAutoConsoleVariableRef CVarChaos_PBDCollisionSolver_Velocity_AveragePointEnabled(TEXT("p.Chaos.PBDCollisionSolver.Velocity.AveragePointEnabled"), bChaos_PBDCollisionSolver_Velocity_AveragePointEnabled, TEXT(""));
	}
	using namespace CVars;

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		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;
		FRealSingle Chaos_PBDCollisionSolver_AutoStiffness_MassRatio2 = 0;

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

Scope (from outer to inner):

file
namespace    Chaos
function     void FPBDCollisionContainerSolver::UpdateVelocityShockPropagation

Source code excerpt:

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

	void FPBDCollisionContainerSolver::SolvePositionImpl(const FReal InDt, const int32 It, const int32 NumIts, const int32 BeginIndex, const int32 EndIndex, const FPBDCollisionSolverSettings& SolverSettings)
	{
		SCOPE_CYCLE_COUNTER(STAT_Collisions_Apply);

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    Private
function     void FPBDCollisionContainerSolverSimd::UpdateVelocityShockPropagation

Source code excerpt:

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

		void FPBDCollisionContainerSolverSimd::UpdateCollisions(const FSolverReal InDt)
		{
			//const FSolverReal Dt = FSolverReal(InDt);

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:


		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(""));
		FAutoConsoleVariableRef CVarChaos_PBDCollisionSolver_Velocity_FrictionEnabled(TEXT("p.Chaos.PBDCollisionSolver.Velocity.FrictionEnabled"), bChaos_PBDCollisionSolver_Velocity_FrictionEnabled, TEXT(""));
		FAutoConsoleVariableRef CVarChaos_PBDCollisionSolver_Velocity_StaticFrictionStiffness(TEXT("p.Chaos.PBDCollisionSolver.Velocity.StaticFriction.Stiffness"), Chaos_PBDCollisionSolver_Velocity_StaticFrictionStiffness, TEXT(""));
		FAutoConsoleVariableRef CVarChaos_PBDCollisionSolver_Velocity_AveragePointEnabled(TEXT("p.Chaos.PBDCollisionSolver.Velocity.AveragePointEnabled"), bChaos_PBDCollisionSolver_Velocity_AveragePointEnabled, TEXT(""));
	}
	using namespace CVars;

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

	{
		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:37

Scope (from outer to inner):

file
namespace    Chaos
namespace    Private
function     void FPBDCollisionSolverJacobi::EnableVelocityShockPropagation

Source code excerpt:

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

		void FPBDCollisionSolverJacobi::DisableShockPropagation()
		{
			SetShockPropagationInvMassScale(FReal(1));
		}

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

	{
		extern float Chaos_PBDCollisionSolver_Position_MinInvMassScale;
		extern float Chaos_PBDCollisionSolver_Velocity_MinInvMassScale;
	}

	namespace Private
	{
		template<int TNumLanes>
		class TPBDCollisionSolverSimd;