p.Chaos.Solver.Sleep.Enabled

p.Chaos.Solver.Sleep.Enabled

#Overview

name: p.Chaos.Solver.Sleep.Enabled

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.Enabled is to control the island sleeping feature in the Chaos physics solver of Unreal Engine 5. This setting is part of the physics simulation system, specifically the Chaos solver.

The Chaos physics solver, which is part of the Experimental Chaos module in Unreal Engine 5, relies on this setting variable. It is used in the IslandManager component of the Chaos solver.

The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be changed at runtime through console commands. It is initialized to true by default.

This variable interacts directly with its associated boolean variable bChaosSolverSleepEnabled. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable controls a performance optimization feature. When enabled, it allows the physics solver to put “islands” of objects to sleep when they’re not moving, which can significantly improve performance. However, disabling it might be necessary for debugging or in scenarios where precise physics simulation is required at all times.

Best practices when using this variable include:

  1. Keeping it enabled for better performance in most scenarios.
  2. Disabling it temporarily for debugging physics issues.
  3. Consider disabling it in situations where you need continuous precise physics simulation for all objects.

Regarding the associated variable bChaosSolverSleepEnabled:

The purpose of bChaosSolverSleepEnabled is the same as p.Chaos.Solver.Sleep.Enabled - to control the island sleeping feature in the Chaos physics solver.

It is used directly in the ProcessSleep function of the FPBDIslandManager class. This function checks the value of bChaosSolverSleepEnabled to determine whether to proceed with sleep processing.

The value of this variable is set in conjunction with p.Chaos.Solver.Sleep.Enabled through the FAutoConsoleVariableRef.

This variable interacts directly with p.Chaos.Solver.Sleep.Enabled, sharing the same value.

Developers should be aware that this is the actual boolean variable used in the code logic, while p.Chaos.Solver.Sleep.Enabled is the console variable name used for external access and modification.

Best practices for using this variable are the same as for p.Chaos.Solver.Sleep.Enabled, as they are effectively the same setting represented in different ways for internal and external use.

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

Scope (from outer to inner):

file
namespace    Chaos::CVars

Source code excerpt:

	/** Cvar to enable/disable the island sleeping */
	bool bChaosSolverSleepEnabled = true;
	FAutoConsoleVariableRef CVarChaosSolverSleepEnabled(TEXT("p.Chaos.Solver.Sleep.Enabled"), bChaosSolverSleepEnabled, TEXT(""));

	/** Cvar to override the sleep counter threshold if necessary */
	int32 ChaosSolverCollisionDefaultSleepCounterThreshold = 20;
	FAutoConsoleVariableRef CVarChaosSolverCollisionDefaultSleepCounterThreshold(TEXT("p.Chaos.Solver.Sleep.Defaults.SleepCounterThreshold"), ChaosSolverCollisionDefaultSleepCounterThreshold, TEXT("Default counter threshold for sleeping.[def:20]"));

	/** Cvar to override the sleep linear threshold if necessary */

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos::CVars

Source code excerpt:


	/** Cvar to enable/disable the island sleeping */
	bool bChaosSolverSleepEnabled = true;
	FAutoConsoleVariableRef CVarChaosSolverSleepEnabled(TEXT("p.Chaos.Solver.Sleep.Enabled"), bChaosSolverSleepEnabled, TEXT(""));

	/** Cvar to override the sleep counter threshold if necessary */
	int32 ChaosSolverCollisionDefaultSleepCounterThreshold = 20;
	FAutoConsoleVariableRef CVarChaosSolverCollisionDefaultSleepCounterThreshold(TEXT("p.Chaos.Solver.Sleep.Defaults.SleepCounterThreshold"), ChaosSolverCollisionDefaultSleepCounterThreshold, TEXT("Default counter threshold for sleeping.[def:20]"));

	/** Cvar to override the sleep linear threshold if necessary */

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

Scope (from outer to inner):

file
namespace    Chaos::Private
function     void FPBDIslandManager::ProcessSleep

Source code excerpt:

	void FPBDIslandManager::ProcessSleep(const FRealSingle Dt)
	{
		if (!CVars::bChaosSolverSleepEnabled)
		{
			return;
		}

		// Isloated particles are not kept in any island and need to be handled separately.
		ProcessParticlesSleep(Dt);