p.PreventInvalidBodyInstanceTransforms

p.PreventInvalidBodyInstanceTransforms

#Overview

name: p.PreventInvalidBodyInstanceTransforms

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.PreventInvalidBodyInstanceTransforms is to control the behavior of the physics engine when encountering invalid transforms during body instance creation. It is primarily used in the physics subsystem of Unreal Engine 5.

This setting variable is used in the Engine module, specifically within the physics engine component. It is referenced in the BodyInstance.cpp file, which is part of the core physics implementation in Unreal Engine.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be modified at runtime through console commands. By default, it is set to true.

The associated variable bPreventInvalidBodyInstanceTransforms directly interacts with p.PreventInvalidBodyInstanceTransforms. They share the same value and purpose.

Developers must be aware that when this variable is set to true (which is the default), any attempt to create a BodyInstance with an invalid transform will fail and generate a warning. This behavior helps to catch potential issues early in the development process.

Best practices when using this variable include:

  1. Keeping it enabled (true) during development to catch invalid transforms early.
  2. Ensuring all transforms are valid before creating BodyInstances to avoid unexpected behavior.
  3. If disabling this check, be prepared to handle potential issues that may arise from invalid transforms in the physics simulation.

Regarding the associated variable bPreventInvalidBodyInstanceTransforms:

By using these variables, developers can ensure the integrity of physics simulations by preventing the creation of body instances with invalid transforms, which could lead to unpredictable or erroneous behavior in the game’s physics.

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

Scope: file

Source code excerpt:

bool bPreventInvalidBodyInstanceTransforms = true;
FAutoConsoleVariableRef CVarbPreventInvalidBodyInstanceTransforms(
	TEXT("p.PreventInvalidBodyInstanceTransforms"), 
	bPreventInvalidBodyInstanceTransforms, 
	TEXT("If true, an attempt to create a BodyInstance with an invalid transform will fail with a warning"));

bool bEnableOverrideSolverDeltaTime = true;
FAutoConsoleVariableRef CVarbEnableOverrideSolverDeltaTime(
	TEXT("p.EnableOverrideSolverDeltaTime"),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

);

bool bPreventInvalidBodyInstanceTransforms = true;
FAutoConsoleVariableRef CVarbPreventInvalidBodyInstanceTransforms(
	TEXT("p.PreventInvalidBodyInstanceTransforms"), 
	bPreventInvalidBodyInstanceTransforms, 
	TEXT("If true, an attempt to create a BodyInstance with an invalid transform will fail with a warning"));

bool bEnableOverrideSolverDeltaTime = true;
FAutoConsoleVariableRef CVarbEnableOverrideSolverDeltaTime(
	TEXT("p.EnableOverrideSolverDeltaTime"),
	bEnableOverrideSolverDeltaTime,

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

Scope (from outer to inner):

file
function     bool FInitBodiesHelperBase::CreateShapesAndActors

Source code excerpt:

		if (!bValidTransform)
		{
			if (bPreventInvalidBodyInstanceTransforms)
			{
				// NaNs are errors and we don't create the physics state
				UE_LOG(LogPhysics, Error, TEXT("Rejecting BodyInstance %d on %s with an invalid transform"), BodyIdx , *SafeDebugName);
				return false;
			}
			else