p.EnableKinematicDeferralPrePhysicsCondition

p.EnableKinematicDeferralPrePhysicsCondition

#Overview

name: p.EnableKinematicDeferralPrePhysicsCondition

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.EnableKinematicDeferralPrePhysicsCondition is to control the behavior of kinematic deferral in the physics simulation, specifically for skeletal mesh components during the PrePhysics tick group.

This setting variable is primarily used in the physics system of Unreal Engine, particularly in the SkeletalMeshComponentPhysics module. It affects how the engine handles kinematic updates for skeletal mesh components.

The value of this variable is set as a console variable (CVar) with a default value of 1. It can be changed at runtime through the console or programmatically.

The associated variable CVarEnableKinematicDeferralPrePhysicsCondition interacts directly with p.EnableKinematicDeferralPrePhysicsCondition, as they share the same value and purpose.

Developers must be aware that this variable specifically influences the behavior of kinematic deferral during the PrePhysics tick. When set to 1, it allows deferral in cases where it would typically be disallowed due to EUpdateTransformFlags, but only during the PrePhysics tick.

Best practices when using this variable include:

  1. Understanding the implications on physics performance and behavior before modifying its value.
  2. Testing thoroughly after changing the value, as it can affect the timing and execution of physics updates.
  3. Consider the interaction with other physics-related settings and variables.

Regarding the associated variable CVarEnableKinematicDeferralPrePhysicsCondition:

This is the actual console variable that controls the behavior described above. It’s defined as a static TAutoConsoleVariable of type int32, which means it can be easily accessed and modified at runtime.

The variable is used in the USkeletalMeshComponent::OnUpdateTransform function to determine whether to allow kinematic deferral during the PrePhysics tick. If the value is 1 and the current tick group is PrePhysics, it sets AllowDeferral to EAllowKinematicDeferral::AllowDeferral.

Developers should be cautious when modifying this variable, as it directly affects the physics behavior of skeletal mesh components. Changes should be thoroughly tested to ensure they don’t introduce unexpected behavior or performance issues in the physics simulation.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SkeletalMeshComponentPhysics.cpp:58

Scope: file

Source code excerpt:

static TAutoConsoleVariable<float> CVarClothTeleportRotationThreshold(TEXT("p.Cloth.TeleportRotationThreshold"), 0.f, TEXT("Require p.Cloth.TeleportOverride. Rotation threshold in degrees, ranging from 0 to 180.\n Conduct teleportation if the character's rotation is greater than this threshold in 1 frame.\n Zero or negative values will skip the check.\n Default 0."));

static TAutoConsoleVariable<int32> CVarEnableKinematicDeferralPrePhysicsCondition(TEXT("p.EnableKinematicDeferralPrePhysicsCondition"), 1, TEXT("If is 1, and deferral would've been disallowed due to EUpdateTransformFlags, allow if in PrePhysics tick. If 0, condition is unchanged."));

//This is the total cloth time split up among multiple computation (updating gpu, updating sim, etc...)
DECLARE_CYCLE_STAT(TEXT("Cloth Total"), STAT_ClothTotalTime, STATGROUP_Physics);
DECLARE_CYCLE_STAT(TEXT("Cloth Writeback"), STAT_ClothWriteback, STATGROUP_Physics);

// Used as a default return value for invalid cloth data access

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SkeletalMeshComponentPhysics.cpp:58

Scope: file

Source code excerpt:

static TAutoConsoleVariable<float> CVarClothTeleportRotationThreshold(TEXT("p.Cloth.TeleportRotationThreshold"), 0.f, TEXT("Require p.Cloth.TeleportOverride. Rotation threshold in degrees, ranging from 0 to 180.\n Conduct teleportation if the character's rotation is greater than this threshold in 1 frame.\n Zero or negative values will skip the check.\n Default 0."));

static TAutoConsoleVariable<int32> CVarEnableKinematicDeferralPrePhysicsCondition(TEXT("p.EnableKinematicDeferralPrePhysicsCondition"), 1, TEXT("If is 1, and deferral would've been disallowed due to EUpdateTransformFlags, allow if in PrePhysics tick. If 0, condition is unchanged."));

//This is the total cloth time split up among multiple computation (updating gpu, updating sim, etc...)
DECLARE_CYCLE_STAT(TEXT("Cloth Total"), STAT_ClothTotalTime, STATGROUP_Physics);
DECLARE_CYCLE_STAT(TEXT("Cloth Writeback"), STAT_ClothWriteback, STATGROUP_Physics);

// Used as a default return value for invalid cloth data access

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/SkeletalMeshComponentPhysics.cpp:1555

Scope (from outer to inner):

file
function     void USkeletalMeshComponent::OnUpdateTransform

Source code excerpt:

			// Probably should rework this entire condition to be more concrete, but do not want to introduce that much risk.
			UWorld* World = GetWorld();
			if (CVarEnableKinematicDeferralPrePhysicsCondition.GetValueOnGameThread())
			{
				if (World && (World->TickGroup == ETickingGroup::TG_PrePhysics))
				{
					AllowDeferral = EAllowKinematicDeferral::AllowDeferral;
				}
			}