p.EnableKinematicDeferralStartPhysicsCondition

p.EnableKinematicDeferralStartPhysicsCondition

#Overview

name: p.EnableKinematicDeferralStartPhysicsCondition

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

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.EnableKinematicDeferralStartPhysicsCondition is to control the deferral of kinematic updates in the physics simulation, particularly during the start physics phase, which is likely called from the replication tick.

This setting variable is primarily used in the physics engine subsystem of Unreal Engine 5, specifically within the Chaos physics implementation. It’s referenced in the PhysScene_Chaos.cpp file, which is part of the Engine’s runtime physics module.

The value of this variable is set through an FAutoConsoleVariableRef, which means it can be adjusted at runtime through console commands. It’s initialized with a default value of 1, allowing kinematic deferral in start physics by default.

This variable interacts closely with GEnableKinematicDeferralStartPhysicsCondition, which is the actual integer variable that stores the value. They share the same value and are used interchangeably in the code.

Developers should be aware that this variable affects the timing of kinematic updates for skeletal meshes. When set to 1 (default), it allows for deferral of kinematic updates during the start physics phase. When set to 0, no deferral occurs in start physics.

Best practices when using this variable include:

  1. Consider the performance implications of enabling or disabling kinematic deferral.
  2. Be aware of how this setting might interact with physics replication and other physics-related systems.
  3. Test thoroughly with both settings (0 and 1) to ensure desired behavior in different scenarios.

Regarding the associated variable GEnableKinematicDeferralStartPhysicsCondition:

This is the actual integer variable that stores the value controlled by p.EnableKinematicDeferralStartPhysicsCondition. It’s used in several key locations within the physics simulation code:

  1. In FPhysScene_Chaos::OnStartFrame, it determines whether kinematic updates on deferred skeletal meshes occur before or after physics replication.
  2. In USkeletalMeshComponent::OnUpdateTransform, it influences whether kinematic deferral is allowed during the StartPhysics tick group.

Developers should treat GEnableKinematicDeferralStartPhysicsCondition as the internal representation of the console variable. When writing C++ code that needs to check this setting, they should use GEnableKinematicDeferralStartPhysicsCondition rather than trying to access the console variable directly.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/Experimental/PhysScene_Chaos.cpp:49

Scope: file

Source code excerpt:


int32 GEnableKinematicDeferralStartPhysicsCondition = 1;
FAutoConsoleVariableRef CVar_EnableKinematicDeferralStartPhysicsCondition(TEXT("p.EnableKinematicDeferralStartPhysicsCondition"), GEnableKinematicDeferralStartPhysicsCondition, TEXT("If is 1, allow kinematics to be deferred in start physics (probably only called from replication tick). If 0, no deferral in startphysics."));

bool GKinematicDeferralCheckValidBodies = true;
FAutoConsoleVariableRef CVar_KinematicDeferralCheckValidBodies(TEXT("p.KinematicDeferralCheckValidBodies"), GKinematicDeferralCheckValidBodies, TEXT("If true, don't attempt to update deferred kinematic skeletal mesh bodies which are pending delete."));

bool GKinematicDeferralUpdateExternalAccelerationStructure = false;
FAutoConsoleVariableRef CVar_KinematicDeferralUpdateExternalAccelerationStructure(TEXT("p.KinematicDeferralUpdateExternalAccelerationStructure"), GKinematicDeferralUpdateExternalAccelerationStructure, TEXT("If true, process any operations in PendingSpatialOperations_External before doing deferred kinematic updates."));

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/Experimental/PhysScene_Chaos.cpp:48

Scope: file

Source code excerpt:

#endif

int32 GEnableKinematicDeferralStartPhysicsCondition = 1;
FAutoConsoleVariableRef CVar_EnableKinematicDeferralStartPhysicsCondition(TEXT("p.EnableKinematicDeferralStartPhysicsCondition"), GEnableKinematicDeferralStartPhysicsCondition, TEXT("If is 1, allow kinematics to be deferred in start physics (probably only called from replication tick). If 0, no deferral in startphysics."));

bool GKinematicDeferralCheckValidBodies = true;
FAutoConsoleVariableRef CVar_KinematicDeferralCheckValidBodies(TEXT("p.KinematicDeferralCheckValidBodies"), GKinematicDeferralCheckValidBodies, TEXT("If true, don't attempt to update deferred kinematic skeletal mesh bodies which are pending delete."));

bool GKinematicDeferralUpdateExternalAccelerationStructure = false;
FAutoConsoleVariableRef CVar_KinematicDeferralUpdateExternalAccelerationStructure(TEXT("p.KinematicDeferralUpdateExternalAccelerationStructure"), GKinematicDeferralUpdateExternalAccelerationStructure, TEXT("If true, process any operations in PendingSpatialOperations_External before doing deferred kinematic updates."));

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/Experimental/PhysScene_Chaos.cpp:2078

Scope (from outer to inner):

file
function     float FPhysScene_Chaos::OnStartFrame

Source code excerpt:


	// CVar determines if this happens before or after phys replication.
	if (GEnableKinematicDeferralStartPhysicsCondition == 0)
	{
		// Update any skeletal meshes that need their bone transforms sent to physics sim
		UpdateKinematicsOnDeferredSkelMeshes();
	}
	
	if (PhysicsReplication)

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/Experimental/PhysScene_Chaos.cpp:2090

Scope (from outer to inner):

file
function     float FPhysScene_Chaos::OnStartFrame

Source code excerpt:


	// CVar determines if this happens before or after phys replication.
	if (GEnableKinematicDeferralStartPhysicsCondition)
	{
		// Update any skeletal meshes that need their bone transforms sent to physics sim
		UpdateKinematicsOnDeferredSkelMeshes();
	}

	OnPhysScenePreTick.Broadcast(this,UseDeltaTime);

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

Scope (from outer to inner):

file
function     void USkeletalMeshComponent::OnUpdateTransform

Source code excerpt:

			}

			if(GEnableKinematicDeferralStartPhysicsCondition)
			{
				if (World && (World->TickGroup == ETickingGroup::TG_StartPhysics))
				{
					AllowDeferral = EAllowKinematicDeferral::AllowDeferral;
				}
			}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/Physics/Experimental/PhysScene_Chaos.h:70

Scope: file

Source code excerpt:

}

extern int32 GEnableKinematicDeferralStartPhysicsCondition;

struct FConstraintBrokenDelegateWrapper
{
	FConstraintBrokenDelegateWrapper(FConstraintInstanceBase* ConstraintInstance);

	void DispatchOnBroken();