p.SkipShapeCreationForEmptyBodySetup

p.SkipShapeCreationForEmptyBodySetup

#Overview

name: p.SkipShapeCreationForEmptyBodySetup

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.SkipShapeCreationForEmptyBodySetup is to optimize the physics simulation by avoiding the creation of unnecessary actors and shapes for body setups without any geometry.

This setting variable is primarily used in the physics engine subsystem of Unreal Engine 5, specifically within the body instance creation process.

The value of this variable is set using the FAutoConsoleVariableRef system, which allows it to be modified at runtime through console commands. It is initialized to false by default.

The associated variable bSkipShapeCreationForEmptyBodySetup directly interacts with p.SkipShapeCreationForEmptyBodySetup. They share the same value and purpose.

Developers must be aware that enabling this variable will prevent the creation of actors and shapes for body setups without geometry. This can lead to performance improvements but may also cause unexpected behavior if certain game logic relies on the existence of these empty actors or shapes.

Best practices when using this variable include:

  1. Testing thoroughly to ensure that skipping shape creation for empty body setups doesn’t break any game logic.
  2. Using this variable in performance-critical scenarios where many empty body setups might exist.
  3. Considering the trade-off between performance gain and potential edge cases in gameplay.

Regarding the associated variable bSkipShapeCreationForEmptyBodySetup:

The purpose of bSkipShapeCreationForEmptyBodySetup is the same as p.SkipShapeCreationForEmptyBodySetup - to skip the creation of actors and shapes for empty body setups.

This variable is used directly in the CreateShapesAndActors() function within the FInitBodiesHelperBase class. It’s checked to determine whether to proceed with shape creation for body setups without geometry.

The value of this variable is set by the console variable p.SkipShapeCreationForEmptyBodySetup.

Developers should be aware that this variable directly affects the physics simulation behavior and should be used cautiously, especially in projects where empty body setups might have a specific purpose.

Best practices for using bSkipShapeCreationForEmptyBodySetup include:

  1. Ensuring that all relevant code paths consider the possibility of this optimization being enabled.
  2. Documenting any assumptions about shape creation in the codebase.
  3. Providing a way to override this behavior for specific objects if necessary.

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

Scope: file

Source code excerpt:

bool bSkipShapeCreationForEmptyBodySetup = false;
FAutoConsoleVariableRef CVarSkipShapeCreationForEmptyBodySetup(
	TEXT("p.SkipShapeCreationForEmptyBodySetup"),
	bSkipShapeCreationForEmptyBodySetup,
	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"),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	TEXT("If true, setting for override solver delta time can be used.  False will disable this feature."));

bool bSkipShapeCreationForEmptyBodySetup = false;
FAutoConsoleVariableRef CVarSkipShapeCreationForEmptyBodySetup(
	TEXT("p.SkipShapeCreationForEmptyBodySetup"),
	bSkipShapeCreationForEmptyBodySetup,
	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,

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

Scope (from outer to inner):

file
function     bool FInitBodiesHelperBase::CreateShapesAndActors

Source code excerpt:

	BodySetup->CreatePhysicsMeshes();

	if (bSkipShapeCreationForEmptyBodySetup)
	{
		if (BodySetup->TriMeshGeometries.IsEmpty() && BodySetup->AggGeom.GetElementCount() == 0)
		{
#if WITH_EDITOR
			// In the editor we may have ended up here because of world trace ignoring our EnableCollision.
			// Since we can't get at the data in that function we check for it here