p.RigidBodyLODThreshold

p.RigidBodyLODThreshold

#Overview

name: p.RigidBodyLODThreshold

The value of this variable can be defined or overridden in .ini config files. 2 .ini config files referencing this setting variable.

This variable is created as a Console Variable (cvar).

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.RigidBodyLODThreshold is to control the Level of Detail (LOD) threshold for rigid body simulations in Unreal Engine’s animation system. It sets a global maximum LOD level at which rigid body nodes are allowed to run, overriding per-node LOD threshold settings.

This setting variable is primarily used by the animation system, specifically within the rigid body simulation subsystem of Unreal Engine 5. It’s part of the AnimGraphRuntime module, which handles advanced animation graph functionalities.

The value of this variable is set through the console variable system. It’s defined as a TAutoConsoleVariable with a default value of -1, which means no override is applied by default.

The p.RigidBodyLODThreshold interacts closely with the LODThreshold property of individual AnimNode_RigidBody nodes. It also has an associated boolean property bUseLocalLODThresholdOnly, which can be set to ignore the global threshold and use only the node-specific threshold.

Developers should be aware that this variable provides a global control over rigid body simulations across all relevant animation nodes. Setting it to a value other than -1 will override individual node settings, potentially affecting performance and visual fidelity across the entire game.

Best practices for using this variable include:

  1. Use it for global optimization, especially on lower-end platforms.
  2. Keep it at -1 during development to test individual node settings.
  3. Fine-tune the value based on performance profiling and visual quality requirements.
  4. Consider using bUseLocalLODThresholdOnly for critical animations that need to bypass the global setting.

Regarding the associated variable CVarRigidBodyLODThreshold:

This is the actual console variable that stores and manages the p.RigidBodyLODThreshold value. It’s used internally by the engine to access and modify the threshold value at runtime.

The CVarRigidBodyLODThreshold is accessed in the GetLODThreshold() function of the FAnimNode_RigidBody class. This function determines the effective LOD threshold by comparing the node’s local threshold with the global one, unless bUseLocalLODThresholdOnly is true.

Developers should note that changes to CVarRigidBodyLODThreshold will affect all rigid body nodes in the game unless they’re specifically set to ignore it. It’s a powerful tool for performance optimization but should be used carefully to avoid unexpected visual artifacts.

#Setting Variables

#References In INI files

Location: <Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:124, section: [IOS_Mid DeviceProfile]

Location: <Workspace>/Projects/Lyra/Config/DefaultDeviceProfiles.ini:537, section: [Android_Mid DeviceProfile]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Private/BoneControllers/AnimNode_RigidBody.cpp:52

Scope: file

Source code excerpt:

FAutoConsoleVariableRef CVarEnableRigidBodyNode(TEXT("p.RigidBodyNode"), bEnableRigidBodyNode, TEXT("Enables/disables the whole rigid body node system. When disabled, avoids all allocations and runtime costs. Can be used to disable RB Nodes on low-end platforms."), ECVF_Scalability);
TAutoConsoleVariable<int32> CVarEnableRigidBodyNodeSimulation(TEXT("p.RigidBodyNode.EnableSimulation"), 1, TEXT("Runtime Enable/Disable RB Node Simulation for debugging and testing (node is initialized and bodies and constraints are created, even when disabled.)"), ECVF_Default);
TAutoConsoleVariable<int32> CVarRigidBodyLODThreshold(TEXT("p.RigidBodyLODThreshold"), -1, TEXT("Max LOD that rigid body node is allowed to run on. Provides a global threshold that overrides per-node the LODThreshold property. -1 means no override."), ECVF_Scalability);

int32 RBAN_MaxSubSteps = 4;
bool bRBAN_EnableTimeBasedReset = true;
bool bRBAN_EnableComponentAcceleration = true;
int32 RBAN_WorldObjectExpiry = 4;
FAutoConsoleVariableRef CVarRigidBodyNodeMaxSteps(TEXT("p.RigidBodyNode.MaxSubSteps"), RBAN_MaxSubSteps, TEXT("Set the maximum number of simulation steps in the update loop"), ECVF_Default);

#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Public/BoneControllers/AnimNode_RigidBody.h:207

Scope: file

Source code excerpt:


public:
	/** Enable if you want to ignore the p.RigidBodyLODThreshold CVAR and force the node to solely use the LOD threshold. */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Performance, meta = (PinHiddenByDefault))
	bool bUseLocalLODThresholdOnly = false;

	/** Override gravity*/
	UPROPERTY(EditAnywhere, Category = Settings, meta = (PinHiddenByDefault, editcondition = "bOverrideWorldGravity"))
	FVector OverrideWorldGravity;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Private/BoneControllers/AnimNode_RigidBody.cpp:52

Scope: file

Source code excerpt:

FAutoConsoleVariableRef CVarEnableRigidBodyNode(TEXT("p.RigidBodyNode"), bEnableRigidBodyNode, TEXT("Enables/disables the whole rigid body node system. When disabled, avoids all allocations and runtime costs. Can be used to disable RB Nodes on low-end platforms."), ECVF_Scalability);
TAutoConsoleVariable<int32> CVarEnableRigidBodyNodeSimulation(TEXT("p.RigidBodyNode.EnableSimulation"), 1, TEXT("Runtime Enable/Disable RB Node Simulation for debugging and testing (node is initialized and bodies and constraints are created, even when disabled.)"), ECVF_Default);
TAutoConsoleVariable<int32> CVarRigidBodyLODThreshold(TEXT("p.RigidBodyLODThreshold"), -1, TEXT("Max LOD that rigid body node is allowed to run on. Provides a global threshold that overrides per-node the LODThreshold property. -1 means no override."), ECVF_Scalability);

int32 RBAN_MaxSubSteps = 4;
bool bRBAN_EnableTimeBasedReset = true;
bool bRBAN_EnableComponentAcceleration = true;
int32 RBAN_WorldObjectExpiry = 4;
FAutoConsoleVariableRef CVarRigidBodyNodeMaxSteps(TEXT("p.RigidBodyNode.MaxSubSteps"), RBAN_MaxSubSteps, TEXT("Set the maximum number of simulation steps in the update loop"), ECVF_Default);

#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Private/BoneControllers/AnimNode_RigidBody.cpp:1553

Scope (from outer to inner):

file
function     int32 FAnimNode_RigidBody::GetLODThreshold

Source code excerpt:

int32 FAnimNode_RigidBody::GetLODThreshold() const
{
	if (bUseLocalLODThresholdOnly || CVarRigidBodyLODThreshold.GetValueOnAnyThread() == -1)
	{
		return LODThreshold;
	}
	else
	{
		if(LODThreshold != -1)
		{
			return FMath::Min(LODThreshold, CVarRigidBodyLODThreshold.GetValueOnAnyThread());
		}
		else
		{
			return CVarRigidBodyLODThreshold.GetValueOnAnyThread();
		}
	}
}

DECLARE_CYCLE_STAT(TEXT("RigidBody_Update"), STAT_RigidBody_Update, STATGROUP_Anim);

#Loc: <Workspace>/Engine/Source/Runtime/AnimGraphRuntime/Public/BoneControllers/AnimNode_RigidBody.h:17

Scope: file

Source code excerpt:

extern ANIMGRAPHRUNTIME_API FAutoConsoleVariableRef CVarEnableRigidBodyNode;
extern ANIMGRAPHRUNTIME_API TAutoConsoleVariable<int32> CVarEnableRigidBodyNodeSimulation;
extern ANIMGRAPHRUNTIME_API TAutoConsoleVariable<int32> CVarRigidBodyLODThreshold;

/** Determines in what space the simulation should run */
UENUM()
enum class ESimulationSpace : uint8
{
	/** Simulate in component space. Moving the entire skeletal mesh will have no affect on velocities */