p.SensitiveSleepThresholdMultiplier

p.SensitiveSleepThresholdMultiplier

#Overview

name: p.SensitiveSleepThresholdMultiplier

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.SensitiveSleepThresholdMultiplier is to control the sleep threshold for physics bodies using the Sensitive sleep family in Unreal Engine’s physics simulation system. This setting variable is part of the physics engine subsystem and is used to fine-tune the behavior of physics objects in terms of when they transition to a sleep state.

The Unreal Engine subsystem that relies on this setting variable is the physics engine, specifically the body instance management part of the physics system. This can be seen from the file location (BodyInstance.cpp) where the variable is defined and used.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through the console or configuration files. The default value is set to 1.0f/20.0f (0.05).

The p.SensitiveSleepThresholdMultiplier interacts directly with its associated variable SensitiveSleepThresholdMultiplier. They share the same value, with the ‘p.’ prefixed version being the console variable that can be accessed externally.

Developers must be aware that this variable specifically affects physics bodies using the Sensitive sleep family. It’s a multiplier, so lower values will make objects more likely to go to sleep (become static) quicker, while higher values will keep objects active for longer.

Best practices when using this variable include:

  1. Use it to fine-tune performance and behavior of sensitive physics objects.
  2. Be cautious when adjusting it, as it can significantly impact simulation accuracy and performance.
  3. Test thoroughly after making changes, especially in scenarios with many physics objects.

Regarding the associated variable SensitiveSleepThresholdMultiplier:

This is the actual float variable that stores the multiplier value. It’s initialized with the same default value (1.0f/20.0f) and is directly modified when the console variable is changed.

The SensitiveSleepThresholdMultiplier is used in the FBodyInstance::GetSleepThresholdMultiplier function to determine the sleep threshold for bodies with the Sensitive sleep family. This function appears to be part of the logic that determines when a physics body should transition to a sleep state.

Developers should be aware that changing this variable will affect all physics bodies using the Sensitive sleep family. It’s a global setting that can have wide-reaching effects on the physics simulation.

Best practices for using SensitiveSleepThresholdMultiplier include:

  1. Consider the performance implications of adjusting this value, especially in scenes with many physics objects.
  2. Use it in conjunction with other sleep family settings to achieve the desired balance between performance and simulation accuracy.
  3. Profile and test thoroughly when making adjustments to ensure the changes don’t negatively impact game performance or behavior.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/BodyInstance.cpp:99

Scope: file

Source code excerpt:

float SensitiveSleepThresholdMultiplier = 1.0f/20.0f;
FAutoConsoleVariableRef CVarSensitiveSleepThresholdMultiplier(
	TEXT("p.SensitiveSleepThresholdMultiplier"),
	SensitiveSleepThresholdMultiplier,
	TEXT("The sleep threshold multiplier to use for bodies using the Sensitive sleep family."));

using namespace PhysicsInterfaceTypes;

bool IsRigidBodyKinematic_AssumesLocked(const FPhysicsActorHandle& InActorRef)

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/BodyInstance.cpp:97

Scope: file

Source code excerpt:

	TEXT("If true, CreateShapesAndActors will not try to create actors and shapes for all instances if the body setup doesn't have any geometry."));

float SensitiveSleepThresholdMultiplier = 1.0f/20.0f;
FAutoConsoleVariableRef CVarSensitiveSleepThresholdMultiplier(
	TEXT("p.SensitiveSleepThresholdMultiplier"),
	SensitiveSleepThresholdMultiplier,
	TEXT("The sleep threshold multiplier to use for bodies using the Sensitive sleep family."));

using namespace PhysicsInterfaceTypes;

bool IsRigidBodyKinematic_AssumesLocked(const FPhysicsActorHandle& InActorRef)
{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/BodyInstance.cpp:3263

Scope (from outer to inner):

file
function     float FBodyInstance::GetSleepThresholdMultiplier

Source code excerpt:

	if (SleepFamily == ESleepFamily::Sensitive)
	{
		return SensitiveSleepThresholdMultiplier;
	}
	else if (SleepFamily == ESleepFamily::Custom)
	{
		return CustomSleepThresholdMultiplier;
	}