p.Chaos.Collision.Stiffness

p.Chaos.Collision.Stiffness

#Overview

name: p.Chaos.Collision.Stiffness

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.Collision.Stiffness is to override the collision solver stiffness in Unreal Engine’s Chaos physics system. This setting variable is part of the collision handling mechanism within the Chaos physics simulation.

The Unreal Engine subsystem that relies on this setting variable is the Experimental Chaos physics module. This can be seen from the file path where the variable is defined and used: Engine/Source/Runtime/Experimental/Chaos/.

The value of this variable is set through a console variable system. It’s initialized with a default value of -1.0f, but can be changed at runtime using the console command “p.Chaos.Collision.Stiffness”.

This variable interacts closely with its associated variable Chaos_Collision_Stiffness. They share the same value, with Chaos_Collision_Stiffness being the actual variable used in the code, while p.Chaos.Collision.Stiffness is the console variable name used to modify it.

Developers must be aware that:

  1. A value of -1.0f or less means the default config setting will be used.
  2. Any value greater than or equal to 0 will override the default collision solver stiffness.

Best practices when using this variable include:

  1. Use it for debugging or fine-tuning physics behavior, not as a primary means of setting collision stiffness.
  2. Be cautious when changing this value, as it can significantly impact the physics simulation’s behavior.
  3. Reset to -1.0f (or remove the override) when not actively debugging to ensure consistent behavior across different environments.

Regarding the associated variable Chaos_Collision_Stiffness:

The purpose of Chaos_Collision_Stiffness is to store the actual stiffness value used in the collision solver calculations.

It’s used directly in the Chaos physics module, specifically in the FPBDCollisionConstraint class.

The value is set either through the console variable system or programmatically in the code.

It interacts with the UpdateMassScales() function of FPBDCollisionConstraint, where it’s used to set the stiffness if its value is greater than or equal to 0.

Developers should be aware that this variable acts as an override. If it’s set to a value >= 0, it will take precedence over any other stiffness calculations.

Best practices include:

  1. Use this variable judiciously, as it can have a significant impact on physics behavior.
  2. When debugging is complete, ensure this variable is reset to -1.0f to allow normal stiffness calculations to take place.
  3. Document any non-default values used during development to ensure reproducibility of physics behavior.

#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/PBDCollisionConstraint.cpp:52

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	// A collision solver stiffness override if >= 0. A value < 0 means use ths config setting.
	FRealSingle Chaos_Collision_Stiffness = -1.0f;
	FAutoConsoleVariableRef CVarChaos_Collision_Stiffness(TEXT("p.Chaos.Collision.Stiffness"), Chaos_Collision_Stiffness, TEXT("Override the collision solver stiffness (if >= 0)"));

	// Enable/Disable the one-way interaction system for collisions
	bool bChaos_Collision_EnableOneWayInteraction = true;
	FAutoConsoleVariableRef CVarChaos_Collision_EnableOneWayInteraction(TEXT("p.Chaos.Collision.EnableOneWayInteraction"), bChaos_Collision_EnableOneWayInteraction, TEXT("Whether the one-way interaction flag is respected in collision constraints"));

	// The stiffness used for collision between one-way objects and other dynamic objects. The stiffness against kinematics and statics is not affected. A value of less than 1

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:


	// A collision solver stiffness override if >= 0. A value < 0 means use ths config setting.
	FRealSingle Chaos_Collision_Stiffness = -1.0f;
	FAutoConsoleVariableRef CVarChaos_Collision_Stiffness(TEXT("p.Chaos.Collision.Stiffness"), Chaos_Collision_Stiffness, TEXT("Override the collision solver stiffness (if >= 0)"));

	// Enable/Disable the one-way interaction system for collisions
	bool bChaos_Collision_EnableOneWayInteraction = true;
	FAutoConsoleVariableRef CVarChaos_Collision_EnableOneWayInteraction(TEXT("p.Chaos.Collision.EnableOneWayInteraction"), bChaos_Collision_EnableOneWayInteraction, TEXT("Whether the one-way interaction flag is respected in collision constraints"));

	// The stiffness used for collision between one-way objects and other dynamic objects. The stiffness against kinematics and statics is not affected. A value of less than 1

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

Scope (from outer to inner):

file
namespace    Chaos
function     void FPBDCollisionConstraint::UpdateMassScales

Source code excerpt:


			// Debug testing for solver stiffness
			if (Chaos_Collision_Stiffness >= 0)
			{
				SetStiffness(Chaos_Collision_Stiffness);
			}
		}
	}

	bool FPBDCollisionConstraint::IsSleeping() const
	{