p.chaos.MinContactSpeedForStrainEval

p.chaos.MinContactSpeedForStrainEval

#Overview

name: p.chaos.MinContactSpeedForStrainEval

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.MinContactSpeedForStrainEval is to set a minimum speed threshold for contact points when evaluating strain in the Chaos physics system of Unreal Engine 5. It is used in the collision handling and rigid body clustering subsystem of the Chaos physics engine.

This setting variable is primarily used in the Chaos module, specifically in the rigid clustering component of the physics system. It’s referenced in the FRigidClustering class, which is part of the experimental Chaos namespace.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through the console or configuration files. It’s initialized with a default value of 1.0f.

The associated variable MinContactSpeedForStrainEval directly interacts with p.chaos.MinContactSpeedForStrainEval. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable affects the strain evaluation in collision handling. It sets a threshold for ignoring contacts where two bodies are essentially at rest relative to each other. This can have implications for performance and simulation accuracy.

Best practices when using this variable include:

  1. Carefully tuning the value to balance performance and simulation accuracy.
  2. Monitoring its impact on the overall physics simulation, especially in scenarios with many resting contacts.
  3. Considering its interaction with other physics parameters, such as the minimum impulse for strain evaluation.

Regarding the associated variable MinContactSpeedForStrainEval:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClustering.cpp:2220

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:


	FRealSingle MinContactSpeedForStrainEval = 1.0f; // Ignore contacts where the two bodies are resting together
	FAutoConsoleVariableRef CVarMinContactSpeedForStrainEval(TEXT("p.chaos.MinContactSpeedForStrainEval"), MinContactSpeedForStrainEval, TEXT("Minimum speed at the contact before accumulating for strain eval "));

	DECLARE_CYCLE_STAT(TEXT("ComputeStrainFromCollision"), STAT_ComputeStrainFromCollision, STATGROUP_Chaos);
	void FRigidClustering::ComputeStrainFromCollision(const FPBDCollisionConstraints& CollisionRule, const FReal Dt)
	{
		SCOPE_CYCLE_COUNTER(STAT_ComputeStrainFromCollision);
		const FRealSingle InvDt = (Dt > SMALL_NUMBER) ? (FRealSingle)(1.0 / Dt) : 1.0f;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClustering.cpp:2219

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	FAutoConsoleVariableRef CVarUseContactSpeedForStrainEval(TEXT("p.chaos.UseContactSpeedForStrainEval"), bUseContactSpeedForStrainThreshold, TEXT("Whether to use contact speed to discard contacts when updating cluster strain (true: use speed, false: use impulse)"));

	FRealSingle MinContactSpeedForStrainEval = 1.0f; // Ignore contacts where the two bodies are resting together
	FAutoConsoleVariableRef CVarMinContactSpeedForStrainEval(TEXT("p.chaos.MinContactSpeedForStrainEval"), MinContactSpeedForStrainEval, TEXT("Minimum speed at the contact before accumulating for strain eval "));

	DECLARE_CYCLE_STAT(TEXT("ComputeStrainFromCollision"), STAT_ComputeStrainFromCollision, STATGROUP_Chaos);
	void FRigidClustering::ComputeStrainFromCollision(const FPBDCollisionConstraints& CollisionRule, const FReal Dt)
	{
		SCOPE_CYCLE_COUNTER(STAT_ComputeStrainFromCollision);
		const FRealSingle InvDt = (Dt > SMALL_NUMBER) ? (FRealSingle)(1.0 / Dt) : 1.0f;

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClustering.cpp:2264

Scope (from outer to inner):

file
namespace    Chaos
function     void FRigidClustering::ComputeStrainFromCollision

Source code excerpt:


				// If we're not approaching at more than the min speed, reject the contact
				if (SpeedAlongNormal > -MinContactSpeedForStrainEval && ContactHandle->GetAccumulatedImpulse().SizeSquared() > FReal(0))
				{
					continue;
				}
			}
			else if (ContactHandle->GetAccumulatedImpulse().Size() < MinImpulseForStrainEval)
			{