p.Cloth.MaxDeltaTimeTeleportMultiplier

p.Cloth.MaxDeltaTimeTeleportMultiplier

#Overview

name: p.Cloth.MaxDeltaTimeTeleportMultiplier

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Cloth.MaxDeltaTimeTeleportMultiplier is to control when cloth simulation should automatically teleport to its new location instead of simulating the transition. This setting is part of Unreal Engine’s cloth simulation system.

The Unreal Engine subsystems that rely on this setting variable are primarily the Clothing System Runtime Common module and the Chaos Cloth Asset Engine plugin. These components are responsible for managing cloth simulations in the engine.

The value of this variable is set as a console variable with a default value of 1.5f. It can be modified at runtime through the console or programmatically.

This variable interacts with another variable named GClothMaxDeltaTimeTeleportMultiplier, which is an auto console variable that shares the same value and purpose.

Developers must be aware that this variable affects the behavior of cloth simulations, particularly in scenarios where there are large time steps between frames. When the delta time exceeds the product of MaxPhysicsDelta and this multiplier, the cloth will teleport to its new position instead of simulating the transition.

Best practices when using this variable include:

  1. Adjusting it carefully to balance between performance and visual quality.
  2. Testing cloth behavior under various frame rate conditions to ensure proper teleportation.
  3. Considering the impact on gameplay, especially in scenarios where cloth movement is crucial.

Regarding the associated variable GClothMaxDeltaTimeTeleportMultiplier:

The purpose of GClothMaxDeltaTimeTeleportMultiplier is identical to p.Cloth.MaxDeltaTimeTeleportMultiplier. It’s an auto console variable that provides a programmatic way to access and modify the setting.

This variable is used directly in the ClothingSimulationContextCommon to determine when to teleport cloth. It’s accessed using the GetValueOnGameThread() method, which suggests it’s designed for runtime modifications.

The value of this variable is set in the same way as p.Cloth.MaxDeltaTimeTeleportMultiplier, with a default of 1.5f.

Developers should be aware that modifying this variable will have an immediate effect on cloth simulations across the entire game. It’s important to consider the performance implications and visual impact of changes to this value.

Best practices for using GClothMaxDeltaTimeTeleportMultiplier include:

  1. Using it for dynamic adjustments to cloth behavior based on game state or performance requirements.
  2. Ensuring that any code modifying this value considers the potential impact on all cloth simulations in the scene.
  3. Documenting any runtime modifications to this variable for easier debugging and maintenance.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/ClothingSystemRuntimeCommon/Private/ClothingSimulation.cpp:15

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> GClothMaxDeltaTimeTeleportMultiplier(
	TEXT("p.Cloth.MaxDeltaTimeTeleportMultiplier"),
	1.5f,
	TEXT("A multiplier of the MaxPhysicsDelta time at which we will automatically just teleport cloth to its new location\n")
	TEXT(" default: 1.5"));

static TAutoConsoleVariable<float> GClothMaxVelocityScale(
	TEXT("p.Cloth.MaxVelocityScale"),

#Loc: <Workspace>/Engine/Plugins/ChaosClothAsset/Source/ChaosClothAssetEngine/Private/ChaosClothAsset/ClothSimulationContext.cpp:20

Scope (from outer to inner):

file
namespace    UE::Chaos::ClothAsset
function     void FClothSimulationContext::Fill

Source code excerpt:


		// Set the teleport mode
		static const IConsoleVariable* const CVarMaxDeltaTimeTeleportMultiplier = IConsoleManager::Get().FindConsoleVariable(TEXT("p.Cloth.MaxDeltaTimeTeleportMultiplier"));
		constexpr float MaxDeltaTimeTeleportMultiplierDefault = 1.5f;
		const float MaxDeltaTimeTeleportMultiplier = CVarMaxDeltaTimeTeleportMultiplier ? CVarMaxDeltaTimeTeleportMultiplier->GetFloat() : MaxDeltaTimeTeleportMultiplierDefault;

		bTeleport = (DeltaTime > MaxDeltaTime * MaxDeltaTimeTeleportMultiplier) ? true : ClothComponent.NeedsTeleport();
		bReset = ClothComponent.NeedsReset();

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/ClothingSystemRuntimeCommon/Private/ClothingSimulation.cpp:14

Scope: file

Source code excerpt:

DEFINE_STAT(STAT_ClothFillContext);

static TAutoConsoleVariable<float> GClothMaxDeltaTimeTeleportMultiplier(
	TEXT("p.Cloth.MaxDeltaTimeTeleportMultiplier"),
	1.5f,
	TEXT("A multiplier of the MaxPhysicsDelta time at which we will automatically just teleport cloth to its new location\n")
	TEXT(" default: 1.5"));

static TAutoConsoleVariable<float> GClothMaxVelocityScale(

#Loc: <Workspace>/Engine/Source/Runtime/ClothingSystemRuntimeCommon/Private/ClothingSimulation.cpp:176

Scope (from outer to inner):

file
function     void FClothingSimulationContextCommon::FillTeleportMode

Source code excerpt:

void FClothingSimulationContextCommon::FillTeleportMode(const USkeletalMeshComponent* InComponent, float InDeltaSeconds, float InMaxPhysicsDelta)
{
	TeleportMode = (InDeltaSeconds > InMaxPhysicsDelta * GClothMaxDeltaTimeTeleportMultiplier.GetValueOnGameThread()) ?
		EClothingTeleportMode::Teleport :
		InComponent->ClothTeleportMode;

	const float MaxVelocityScale = FMath::Clamp(GClothMaxVelocityScale.GetValueOnGameThread(), 0.f, 1.f);
	const float ComponentVelocityScale = InComponent->ClothVelocityScale;