p.Chaos.CollisionSpring.MaxTimer

p.Chaos.CollisionSpring.MaxTimer

#Overview

name: p.Chaos.CollisionSpring.MaxTimer

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.CollisionSpring.MaxTimer is to control the duration for which a kinematic collision connection is remembered after it has moved more than a certain thickness away. This setting variable is part of the Chaos physics system in Unreal Engine 5, specifically related to collision handling for soft bodies.

This setting variable is primarily used in the Chaos module, which is an experimental physics system in Unreal Engine 5. It’s specifically used in the collision spring constraints for soft body simulations.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 0.1 seconds but can be modified at runtime through console commands or configuration files.

The associated variable KinematicColliderMaxTimer directly interacts with p.Chaos.CollisionSpring.MaxTimer. They share the same value, with KinematicColliderMaxTimer being the actual variable used in the code logic.

Developers must be aware that increasing this value can reduce jitter in soft body simulations, but at the cost of increased computation. This trade-off should be carefully considered based on the specific requirements of the game or application.

Best practices when using this variable include:

  1. Fine-tuning the value based on the specific needs of the soft body simulation in your game.
  2. Monitoring performance impact when adjusting this value, especially in performance-critical scenarios.
  3. Using it in conjunction with other Chaos physics settings for optimal results.
  4. Testing thoroughly with different values to find the best balance between visual quality and performance.

Regarding the associated variable KinematicColliderMaxTimer:

The purpose of KinematicColliderMaxTimer is to store the actual value used in the physics calculations for the maximum time to remember a kinematic collision connection.

This variable is used directly in the Chaos physics system, specifically in the PBDCollisionSpringConstraintsBase class.

Its value is set either as a constant in shipping builds or through the console variable system in non-shipping builds.

It interacts directly with the p.Chaos.CollisionSpring.MaxTimer CVar, reflecting any changes made to that setting.

Developers should be aware that this variable is used in time-critical physics calculations, so its value can have a direct impact on both the accuracy and performance of soft body simulations.

Best practices for KinematicColliderMaxTimer include:

  1. Avoid modifying it directly in code; instead, use the p.Chaos.CollisionSpring.MaxTimer CVar to ensure consistency.
  2. Consider the performance implications when adjusting this value, especially in scenarios with many soft body objects.
  3. Use profiling tools to measure the impact of different values on your specific use case.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

#else
Chaos::Softs::FSolverReal KinematicColliderMaxTimer = (Chaos::Softs::FSolverReal)0.1f; 
FAutoConsoleVariableRef CVarChaosCollisionSpringMaxTimer(TEXT("p.Chaos.CollisionSpring.MaxTimer"), KinematicColliderMaxTimer, TEXT("Amount of time (in seconds) to remember a kinematic collision connection after it has moved more than Thickness away. Increasing this can reduce jitter at the cost of more computation."));

Chaos::Softs::FSolverReal KinematicColliderFalloffMultiplier = (Chaos::Softs::FSolverReal)1.f;
FAutoConsoleVariableRef CVarChaosCollisionSpringFalloffMultiplier(TEXT("p.Chaos.CollisionSpring.FalloffMultiplier"), KinematicColliderFalloffMultiplier, TEXT("Tangential distance away from a triangle (scaled by thickness) beyond which a point isn't considered to be kinematically colliding"));

Chaos::Softs::FSolverReal KinematicColliderMaxDepthMultiplier = (Chaos::Softs::FSolverReal)10.f;
FAutoConsoleVariableRef CVarChaosCollisionSpringMaxDepthMultiplier(TEXT("p.Chaos.CollisionSpring.MaxDepthMultiplier"), KinematicColliderMaxDepthMultiplier, TEXT("Penetration depth beyond which we ignore the kinematic collision (so you don't push through the wrong side)"));

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:


#if UE_BUILD_SHIPPING
static constexpr Chaos::Softs::FSolverReal KinematicColliderMaxTimer = (Chaos::Softs::FSolverReal)0.1f;
static constexpr Chaos::Softs::FSolverReal KinematicColliderFalloffMultiplier = (Chaos::Softs::FSolverReal)1.f;
static constexpr Chaos::Softs::FSolverReal KinematicColliderMaxDepthMultiplier = (Chaos::Softs::FSolverReal)10.f;
#else
Chaos::Softs::FSolverReal KinematicColliderMaxTimer = (Chaos::Softs::FSolverReal)0.1f; 
FAutoConsoleVariableRef CVarChaosCollisionSpringMaxTimer(TEXT("p.Chaos.CollisionSpring.MaxTimer"), KinematicColliderMaxTimer, TEXT("Amount of time (in seconds) to remember a kinematic collision connection after it has moved more than Thickness away. Increasing this can reduce jitter at the cost of more computation."));

Chaos::Softs::FSolverReal KinematicColliderFalloffMultiplier = (Chaos::Softs::FSolverReal)1.f;
FAutoConsoleVariableRef CVarChaosCollisionSpringFalloffMultiplier(TEXT("p.Chaos.CollisionSpring.FalloffMultiplier"), KinematicColliderFalloffMultiplier, TEXT("Tangential distance away from a triangle (scaled by thickness) beyond which a point isn't considered to be kinematically colliding"));

Chaos::Softs::FSolverReal KinematicColliderMaxDepthMultiplier = (Chaos::Softs::FSolverReal)10.f;
FAutoConsoleVariableRef CVarChaosCollisionSpringMaxDepthMultiplier(TEXT("p.Chaos.CollisionSpring.MaxDepthMultiplier"), KinematicColliderMaxDepthMultiplier, TEXT("Penetration depth beyond which we ignore the kinematic collision (so you don't push through the wrong side)"));

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDCollisionSpringConstraintsBase.cpp:369

Scope (from outer to inner):

file
namespace    Chaos::Softs
function     void FPBDCollisionSpringConstraintsBase::Init
lambda-function

Source code excerpt:

				{
					TimerIter.Value() += Dt;
					if (TimerIter.Value() > KinematicColliderMaxTimer)
					{
						TimerIter.RemoveCurrent();
					}
				}

				if(CollidableSubMesh.GetKinematicColliderSubMesh().GetNumElements() > 0)