p.Chaos.Solver.Sleep.Defaults.LinearSleepThreshold
p.Chaos.Solver.Sleep.Defaults.LinearSleepThreshold
#Overview
name: p.Chaos.Solver.Sleep.Defaults.LinearSleepThreshold
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Default linear threshold for sleeping.[def:0.001]
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.Solver.Sleep.Defaults.LinearSleepThreshold is to define the default linear threshold for sleeping in the Chaos physics solver. This setting is part of the sleep system in Unreal Engine’s Chaos physics simulation, which helps optimize performance by putting objects to sleep when they have minimal movement.
This setting variable is primarily used in the Chaos physics subsystem, specifically within the Island Manager component. It’s part of the Experimental Chaos module in Unreal Engine 5.
The value of this variable is set to 0.001f by default, which represents 0.001 unit mass cm. It’s defined and initialized in the Chaos::CVars namespace within the IslandManager.cpp file.
This variable interacts closely with ChaosSolverCollisionDefaultLinearSleepThreshold, which is its associated variable. They share the same value and are used interchangeably in the code.
Developers must be aware that this variable affects the performance and accuracy of physics simulations. A lower threshold will make objects go to sleep more easily, potentially improving performance but at the cost of less accurate simulations for slow-moving objects. Conversely, a higher threshold will keep more objects awake, leading to more accurate simulations but potentially impacting performance.
Best practices when using this variable include:
- Carefully consider the trade-off between performance and simulation accuracy when adjusting this value.
- Test thoroughly with different values to find the optimal balance for your specific game or application.
- Consider the scale of your game world when setting this value, as it’s measured in unit mass cm.
- Be aware that this is a global setting and will affect all objects in the simulation unless overridden locally.
Regarding the associated variable ChaosSolverCollisionDefaultLinearSleepThreshold:
This variable serves the same purpose as p.Chaos.Solver.Sleep.Defaults.LinearSleepThreshold and is used interchangeably in the code. It’s defined in the same file (IslandManager.cpp) and is also part of the Chaos physics solver’s sleep system.
The value of ChaosSolverCollisionDefaultLinearSleepThreshold is set to 0.001f by default, matching p.Chaos.Solver.Sleep.Defaults.LinearSleepThreshold.
This variable is used directly in the GetIslandParticleSleepThresholds function to calculate the sleep linear threshold for particles in the physics simulation. It’s multiplied by a ParticleSleepThresholdMultiplier to allow for fine-tuning of the threshold on a per-particle basis.
Developers should be aware that changes to either p.Chaos.Solver.Sleep.Defaults.LinearSleepThreshold or ChaosSolverCollisionDefaultLinearSleepThreshold will affect the other, as they are essentially two ways to access the same setting.
Best practices for using ChaosSolverCollisionDefaultLinearSleepThreshold are the same as those for p.Chaos.Solver.Sleep.Defaults.LinearSleepThreshold, given their shared purpose and value.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Island/IslandManager.cpp:55
Scope (from outer to inner):
file
namespace Chaos::CVars
Source code excerpt:
/** Cvar to override the sleep linear threshold if necessary */
FRealSingle ChaosSolverCollisionDefaultLinearSleepThreshold = 0.001f; // .001 unit mass cm
FAutoConsoleVariableRef CVarChaosSolverCollisionDefaultLinearSleepThreshold(TEXT("p.Chaos.Solver.Sleep.Defaults.LinearSleepThreshold"), ChaosSolverCollisionDefaultLinearSleepThreshold, TEXT("Default linear threshold for sleeping.[def:0.001]"));
/** Cvar to override the sleep angular threshold if necessary */
FRealSingle ChaosSolverCollisionDefaultAngularSleepThreshold = 0.0087f; //~1/2 unit mass degree
FAutoConsoleVariableRef CVarChaosSolverCollisionDefaultAngularSleepThreshold(TEXT("p.Chaos.Solver.Sleep.Defaults.AngularSleepThreshold"), ChaosSolverCollisionDefaultAngularSleepThreshold, TEXT("Default angular threshold for sleeping.[def:0.0087]"));
/** The size of object for which the angular sleep threshold is defined. Large objects reduce the threshold propertionally. 0 means do not apply size scale. */
#Associated Variable and Callsites
This variable is associated with another variable named ChaosSolverCollisionDefaultLinearSleepThreshold
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Island/IslandManager.cpp:54
Scope (from outer to inner):
file
namespace Chaos::CVars
Source code excerpt:
/** Cvar to override the sleep linear threshold if necessary */
FRealSingle ChaosSolverCollisionDefaultLinearSleepThreshold = 0.001f; // .001 unit mass cm
FAutoConsoleVariableRef CVarChaosSolverCollisionDefaultLinearSleepThreshold(TEXT("p.Chaos.Solver.Sleep.Defaults.LinearSleepThreshold"), ChaosSolverCollisionDefaultLinearSleepThreshold, TEXT("Default linear threshold for sleeping.[def:0.001]"));
/** Cvar to override the sleep angular threshold if necessary */
FRealSingle ChaosSolverCollisionDefaultAngularSleepThreshold = 0.0087f; //~1/2 unit mass degree
FAutoConsoleVariableRef CVarChaosSolverCollisionDefaultAngularSleepThreshold(TEXT("p.Chaos.Solver.Sleep.Defaults.AngularSleepThreshold"), ChaosSolverCollisionDefaultAngularSleepThreshold, TEXT("Default angular threshold for sleeping.[def:0.0087]"));
/** The size of object for which the angular sleep threshold is defined. Large objects reduce the threshold propertionally. 0 means do not apply size scale. */
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Island/IslandManager.cpp:172
Scope (from outer to inner):
file
namespace Chaos::Private
function bool GetIslandParticleSleepThresholds
Source code excerpt:
else
{
OutSleepLinearThreshold = ParticleSleepThresholdMultiplier * CVars::ChaosSolverCollisionDefaultLinearSleepThreshold;
OutSleepAngularThreshold = ParticleSleepThresholdMultiplier * CVars::ChaosSolverCollisionDefaultAngularSleepThreshold;
OutSleepCounterThreshold = CVars::ChaosSolverCollisionDefaultSleepCounterThreshold;
}
// Adjust angular threshold for size. It is equivalent to converting the angular threshold into a linear
// movement threshold at the extreme points on the particle.