p.Chaos.Solver.Sleep.AngularSleepThresholdSize

p.Chaos.Solver.Sleep.AngularSleepThresholdSize

#Overview

name: p.Chaos.Solver.Sleep.AngularSleepThresholdSize

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.AngularSleepThresholdSize is to scale the angular sleep threshold for rigid bodies in the Chaos physics system based on their size. This setting is part of the sleep system in Unreal Engine’s physics simulation, which helps optimize performance by putting objects to sleep when they’re not moving significantly.

This setting variable is primarily used in the Chaos physics solver, which is part of Unreal Engine’s experimental physics system. It’s specifically utilized in the Island Manager component of the Chaos system, which manages groups of interacting physics objects.

The value of this variable is set through a console variable (CVar) system, allowing it to be adjusted at runtime. It’s initialized to 0 by default, which means size-based scaling is disabled.

The associated variable ChaosSolverCollisionAngularSleepThresholdSize directly interacts with p.Chaos.Solver.Sleep.AngularSleepThresholdSize. They share the same value and purpose.

Developers must be aware that:

  1. This variable only affects the angular sleep threshold, not the linear sleep threshold.
  2. A value of 0 disables size-based scaling of the angular sleep threshold.
  3. The scaling is applied inversely proportional to the object’s size, meaning larger objects will have a lower angular sleep threshold.

Best practices when using this variable include:

  1. Adjust it carefully, as it can significantly impact simulation performance and behavior.
  2. Test thoroughly with various object sizes to ensure desired behavior across your game’s physics interactions.
  3. Consider exposing this as a project setting for easier tuning in different game scenarios.

Regarding the associated variable ChaosSolverCollisionAngularSleepThresholdSize:

When working with ChaosSolverCollisionAngularSleepThresholdSize, developers should treat it the same as p.Chaos.Solver.Sleep.AngularSleepThresholdSize, as they are essentially the same setting exposed through different mechanisms.

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

Scope (from outer to inner):

file
namespace    Chaos::CVars

Source code excerpt:

	// @todo(chaos): male this a project setting or something
	FRealSingle ChaosSolverCollisionAngularSleepThresholdSize = 0;
	FAutoConsoleVariableRef CVarChaosSolverCollisionAngularSleepThresholdSize(TEXT("p.Chaos.Solver.Sleep.AngularSleepThresholdSize"), ChaosSolverCollisionAngularSleepThresholdSize, TEXT("Scales the angular threshold based on size (0 to disable size based scaling)"));

	/* Cvar to increase the sleep counter threshold for floating particles */
	int32 IsolatedParticleSleepCounterThresholdMultiplier = 1;
	FAutoConsoleVariableRef CVarChaosSolverIsolatedParticleSleepCounterThresholdMultiplier(TEXT("p.Chaos.Solver.Sleep.IsolatedParticle.CounterMultiplier"), IsolatedParticleSleepCounterThresholdMultiplier, TEXT("A multiplier applied to SleepCounterThreshold for floating particles"));

	/* Cvar to adjust the sleep linear threshold for floating particles */

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos::CVars

Source code excerpt:


	/** 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;
	FAutoConsoleVariableRef CVarChaosSolverCollisionAngularSleepThresholdSize(TEXT("p.Chaos.Solver.Sleep.AngularSleepThresholdSize"), ChaosSolverCollisionAngularSleepThresholdSize, TEXT("Scales the angular threshold based on size (0 to disable size based scaling)"));

	/* Cvar to increase the sleep counter threshold for floating particles */
	int32 IsolatedParticleSleepCounterThresholdMultiplier = 1;
	FAutoConsoleVariableRef CVarChaosSolverIsolatedParticleSleepCounterThresholdMultiplier(TEXT("p.Chaos.Solver.Sleep.IsolatedParticle.CounterMultiplier"), IsolatedParticleSleepCounterThresholdMultiplier, TEXT("A multiplier applied to SleepCounterThreshold for floating particles"));

	/* Cvar to adjust the sleep linear threshold for floating particles */

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

Scope (from outer to inner):

file
namespace    Chaos::Private
function     bool GetIslandParticleSleepThresholds

Source code excerpt:

			// 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;
			if ((AngularSleepThresholdSize > 0) && Rigid->HasBounds())
			{
				const FRealSingle RigidSize = FRealSingle(Rigid->LocalBounds().Extents().GetMax());
				if (RigidSize > AngularSleepThresholdSize)
				{
					const FRealSingle ThresholdScale = AngularSleepThresholdSize / RigidSize;