p.Chaos.Solver.Sleep.Defaults.AngularSleepThreshold

p.Chaos.Solver.Sleep.Defaults.AngularSleepThreshold

#Overview

name: p.Chaos.Solver.Sleep.Defaults.AngularSleepThreshold

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.Solver.Sleep.Defaults.AngularSleepThreshold is to set the default angular threshold for sleeping in the Chaos physics solver. This setting is part of the Chaos physics system in Unreal Engine 5, which is responsible for simulating physical interactions between objects in the game world.

This setting variable is primarily used in the Chaos subsystem, specifically within the Island Manager component of the Chaos solver. It’s part of the collision and sleep detection mechanism for rigid bodies in the physics simulation.

The value of this variable is set through a console variable (CVar) system, which allows for runtime modification. It’s initialized with a default value of 0.0087 (approximately 1/2 unit mass degree), but can be changed during runtime or through configuration files.

The associated variable ChaosSolverCollisionDefaultAngularSleepThreshold directly interacts with this setting. They share the same value, with the CVar system binding them together.

Developers should be aware that this threshold is used to determine when a rigid body should enter a “sleep” state in the physics simulation. A sleeping object is considered to be at rest and is not actively simulated, which can improve performance. The angular sleep threshold specifically relates to the rotational movement of objects.

Best practices when using this variable include:

  1. Carefully adjusting the value to balance performance and simulation accuracy. A too high value might cause objects to sleep prematurely, while a too low value might prevent objects from sleeping, potentially impacting performance.

  2. Consider the scale of your game world and objects when setting this value. The default value might not be suitable for all scenarios.

  3. Be aware that this is a global default setting. For more fine-grained control, individual objects can have their sleep thresholds adjusted through the FChaosPhysicsMaterial.

  4. Use in conjunction with the linear sleep threshold (ChaosSolverCollisionDefaultLinearSleepThreshold) for comprehensive sleep behavior control.

  5. Monitor performance and simulation behavior when adjusting this value, as it can have significant impacts on both.

Regarding the associated variable ChaosSolverCollisionDefaultAngularSleepThreshold:

This is the actual storage variable for the angular sleep threshold. It’s used directly in the physics calculations within the Chaos solver. The CVar system binds this variable to the console-accessible p.Chaos.Solver.Sleep.Defaults.AngularSleepThreshold, allowing for runtime modifications.

The variable is used in the GetIslandParticleSleepThresholds function to set the sleep thresholds for particles that don’t have specific physics materials assigned. This ensures that all objects in the simulation have a defined angular sleep threshold, even if not explicitly set.

Developers should note that this variable can be scaled based on object size if ChaosSolverCollisionAngularSleepThresholdSize is set to a non-zero value, allowing for size-dependent sleep 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/Island/IslandManager.cpp:59

Scope (from outer to inner):

file
namespace    Chaos::CVars

Source code excerpt:

	/** 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. */
	// E.g., if ChaosSolverCollisionAngularSleepThresholdSize=100, an objects with a bounds of 500 will have 1/5x the sleep threshold.
	// We are effectively converting the angular threshold into a linear threshold calculated at the object extents.
	// @todo(chaos): male this a project setting or something
	FRealSingle ChaosSolverCollisionAngularSleepThresholdSize = 0;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Island/IslandManager.cpp:58

Scope (from outer to inner):

file
namespace    Chaos::CVars

Source code excerpt:


	/** 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. */
	// E.g., if ChaosSolverCollisionAngularSleepThresholdSize=100, an objects with a bounds of 500 will have 1/5x the sleep threshold.
	// We are effectively converting the angular threshold into a linear threshold calculated at the object extents.
	// @todo(chaos): male this a project setting or something
	FRealSingle ChaosSolverCollisionAngularSleepThresholdSize = 0;

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Island/IslandManager.cpp:173

Scope (from outer to inner):

file
namespace    Chaos::Private
function     bool GetIslandParticleSleepThresholds

Source code excerpt:

			{
				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.
			const FRealSingle AngularSleepThresholdSize = CVars::ChaosSolverCollisionAngularSleepThresholdSize;