p.Chaos.Collision.GBFCharacteristicTimeRatio

p.Chaos.Collision.GBFCharacteristicTimeRatio

#Overview

name: p.Chaos.Collision.GBFCharacteristicTimeRatio

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.Collision.GBFCharacteristicTimeRatio is to control the ratio between characteristic time and the time step (Dt) in the Chaos physics simulation system of Unreal Engine 5. This variable is specifically used in collision handling within the physics simulation.

This setting variable is primarily used in the Chaos physics subsystem, which is part of Unreal Engine’s experimental physics simulation module. It’s referenced in the PBDCollisionConstraint.cpp file, which handles collision constraints for Position Based Dynamics (PBD) in the Chaos system.

The value of this variable is set through an FAutoConsoleVariableRef, which means it can be adjusted at runtime through console commands or configuration files. Its default value is 1.0f.

The associated variable Chaos_GBFCharacteristicTimeRatio directly interacts with p.Chaos.Collision.GBFCharacteristicTimeRatio. They share the same value, with Chaos_GBFCharacteristicTimeRatio being the actual variable used in the code calculations.

Developers should be aware that this variable affects the calculation of characteristic time in collision handling. It’s used in determining the constraint direction and step size in collision resolution, particularly in scenarios involving gravity and resting contact.

Best practices when using this variable include:

  1. Understanding its impact on collision behavior, especially in gravity-dependent scenarios.
  2. Adjusting it carefully, as it can affect the stability and accuracy of the physics simulation.
  3. Testing thoroughly after any modifications, as it can influence the overall feel of physics interactions in the game.

Regarding the associated variable Chaos_GBFCharacteristicTimeRatio:

The purpose of Chaos_GBFCharacteristicTimeRatio is to store and provide the actual value used in physics calculations that correspond to the p.Chaos.Collision.GBFCharacteristicTimeRatio setting.

It’s used directly in the Chaos physics subsystem, specifically in collision constraint calculations.

Its value is set by the FAutoConsoleVariableRef linked to p.Chaos.Collision.GBFCharacteristicTimeRatio.

This variable interacts with the time step (Dt) in physics calculations, influencing the characteristic time used in collision resolution.

Developers should be aware that modifying p.Chaos.Collision.GBFCharacteristicTimeRatio will directly affect Chaos_GBFCharacteristicTimeRatio and thus the physics behavior.

Best practices include monitoring this variable’s effects on physics behavior when adjusting p.Chaos.Collision.GBFCharacteristicTimeRatio, and considering its impact in conjunction with other physics parameters for optimal simulation results.

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:


	FRealSingle Chaos_GBFCharacteristicTimeRatio = 1.0f;
	FAutoConsoleVariableRef CVarChaos_GBFCharacteristicTimeRatio(TEXT("p.Chaos.Collision.GBFCharacteristicTimeRatio"), Chaos_GBFCharacteristicTimeRatio, TEXT("The ratio between characteristic time and Dt"));

	bool bChaos_Manifold_EnableFrictionRestore = true;
	FAutoConsoleVariableRef CVarChaos_Manifold_EnableFrictionRestore(TEXT("p.Chaos.Collision.Manifold.EnableFrictionRestore"), bChaos_Manifold_EnableFrictionRestore, TEXT(""));
	
	// The margin to use when we are colliding a convex shape against a zero-margin shape. E.g., Box-Triangle.
	// When both shapes have a margin we use the minimum margin, but we don't want to use a zero margin because we hit the EPA degenerate case

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:



	FRealSingle Chaos_GBFCharacteristicTimeRatio = 1.0f;
	FAutoConsoleVariableRef CVarChaos_GBFCharacteristicTimeRatio(TEXT("p.Chaos.Collision.GBFCharacteristicTimeRatio"), Chaos_GBFCharacteristicTimeRatio, TEXT("The ratio between characteristic time and Dt"));

	bool bChaos_Manifold_EnableFrictionRestore = true;
	FAutoConsoleVariableRef CVarChaos_Manifold_EnableFrictionRestore(TEXT("p.Chaos.Collision.Manifold.EnableFrictionRestore"), bChaos_Manifold_EnableFrictionRestore, TEXT(""));
	
	// The margin to use when we are colliding a convex shape against a zero-margin shape. E.g., Box-Triangle.
	// When both shapes have a margin we use the minimum margin, but we don't want to use a zero margin because we hit the EPA degenerate case

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

Scope (from outer to inner):

file
namespace    Chaos
function     ECollisionConstraintDirection FPBDCollisionConstraint::GetConstraintDirection

Source code excerpt:

		}
		// D\tau is the chacteristic time (as in GBF paper Sec 8.1)
		const FReal Dtau = Dt * Chaos_GBFCharacteristicTimeRatio; 

		const FVec3 Normal = CalculateWorldContactNormal();
		const FReal Phi = GetPhi();
		if (GetPhi() >= GetCullDistance())
		{
			return NoRestingDependency;

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

Scope (from outer to inner):

file
namespace    Chaos
function     ECollisionConstraintDirection FPBDCollisionConstraint::GetConstraintDirection

Source code excerpt:

		// Theoretically this should be 0.5 * GravityMagnitude * Dtau * Dtau.
		// Omitting 0.5 to be more consistent with our integration scheme.
		// Multiplying 0.5 can alternatively be achieved by setting Chaos_GBFCharacteristicTimeRatio=sqrt(0.5)
		const FReal StepSize = GravitySize * Dtau * Dtau; 
		const FReal NormalDotG = FVec3::DotProduct(Normal, GravityDirection);
		const FReal NormalDirectionThreshold = 0.1f; // Hack
		if (NormalDotG < -NormalDirectionThreshold) // Object 0 rests on object 1
		{
			if (Phi + NormalDotG * StepSize < 0) // Hack to simulate object 0 falling (as in GBF paper Sec 8.1)