p.Cloth.TeleportOverride

p.Cloth.TeleportOverride

#Overview

name: p.Cloth.TeleportOverride

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.Cloth.TeleportOverride is to control the cloth teleportation behavior in Unreal Engine’s physics simulation, specifically for skeletal mesh components with cloth simulation.

This setting variable is primarily used in the physics system, particularly in the cloth simulation subsystem of Unreal Engine. It’s referenced in the SkeletalMeshComponentPhysics.cpp file, which is part of the Engine module.

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

Several other variables interact with p.Cloth.TeleportOverride:

  1. p.Cloth.ResetAfterTeleport
  2. p.Cloth.TeleportDistanceThreshold
  3. p.Cloth.TeleportRotationThreshold

These variables are only considered when p.Cloth.TeleportOverride is set to true.

Developers must be aware that when this variable is set to true, it overrides the skeletal mesh properties related to cloth teleportation. This means that the console variable values will take precedence over any values set in the Unreal Editor or through other means.

Best practices when using this variable include:

  1. Use it for debugging or testing purposes, as it overrides default behavior.
  2. Be cautious when enabling it in production builds, as it may affect performance or visual quality.
  3. When enabled, make sure to set appropriate values for the associated variables (ResetAfterTeleport, TeleportDistanceThreshold, and TeleportRotationThreshold).

Regarding the associated variable CVarClothTeleportOverride:

The purpose of CVarClothTeleportOverride is to store the actual value of the p.Cloth.TeleportOverride console variable. It’s an implementation detail of how console variables are managed in Unreal Engine.

This variable is used in the CheckClothTeleport function of the USkeletalMeshComponent class to determine whether to use the override values for cloth teleportation.

The value of CVarClothTeleportOverride is set automatically by the engine when the p.Cloth.TeleportOverride console variable is changed.

Developers typically don’t need to interact with CVarClothTeleportOverride directly. Instead, they should use the p.Cloth.TeleportOverride console variable to control the behavior.

When using this variable, developers should be aware that it’s checked on the game thread, which means changes to this variable will only take effect on the next frame.

Best practices for CVarClothTeleportOverride are the same as for p.Cloth.TeleportOverride, as they represent the same setting.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

static TAutoConsoleVariable<int32> CVarClothPhysicsTickWaitForParallelClothTask(TEXT("p.ClothPhysics.WaitForParallelClothTask"), 0, TEXT("If 1, always wait for cloth task completion in the Cloth Tick function. If 0, wait at end-of-frame updates instead if allowed by component settings"));

static TAutoConsoleVariable<bool> CVarClothTeleportOverride(TEXT("p.Cloth.TeleportOverride"), false, TEXT("Force console variable teleport override values over skeletal mesh properties.\n Default: false."));
static TAutoConsoleVariable<bool> CVarClothResetAfterTeleport(TEXT("p.Cloth.ResetAfterTeleport"), true, TEXT("Require p.Cloth.TeleportOverride. Reset the clothing after moving the clothing position (called teleport).\n Default: true."));
static TAutoConsoleVariable<float> CVarClothTeleportDistanceThreshold(TEXT("p.Cloth.TeleportDistanceThreshold"), 300.f, TEXT("Require p.Cloth.TeleportOverride. Conduct teleportation if the character's movement is greater than this threshold in 1 frame.\n Zero or negative values will skip the check.\n Default: 300."));
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."));

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

static TAutoConsoleVariable<int32> CVarClothPhysicsTickWaitForParallelClothTask(TEXT("p.ClothPhysics.WaitForParallelClothTask"), 0, TEXT("If 1, always wait for cloth task completion in the Cloth Tick function. If 0, wait at end-of-frame updates instead if allowed by component settings"));

static TAutoConsoleVariable<bool> CVarClothTeleportOverride(TEXT("p.Cloth.TeleportOverride"), false, TEXT("Force console variable teleport override values over skeletal mesh properties.\n Default: false."));
static TAutoConsoleVariable<bool> CVarClothResetAfterTeleport(TEXT("p.Cloth.ResetAfterTeleport"), true, TEXT("Require p.Cloth.TeleportOverride. Reset the clothing after moving the clothing position (called teleport).\n Default: true."));
static TAutoConsoleVariable<float> CVarClothTeleportDistanceThreshold(TEXT("p.Cloth.TeleportDistanceThreshold"), 300.f, TEXT("Require p.Cloth.TeleportOverride. Conduct teleportation if the character's movement is greater than this threshold in 1 frame.\n Zero or negative values will skip the check.\n Default: 300."));
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."));

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

Scope (from outer to inner):

file
function     void USkeletalMeshComponent::CheckClothTeleport

Source code excerpt:

	float TeleportRotationThresholdOverride;
	float ClothTeleportCosineThresholdInRadOverride;
	if (CVarClothTeleportOverride.GetValueOnGameThread())
	{
		bResetAfterTeleportOverride = CVarClothResetAfterTeleport.GetValueOnGameThread();
		TeleportDistanceThresholdOverride = CVarClothTeleportDistanceThreshold.GetValueOnGameThread();
		ClothTeleportDistThresholdSquaredOverride = FMath::Square(TeleportDistanceThresholdOverride);
		TeleportRotationThresholdOverride = CVarClothTeleportRotationThreshold.GetValueOnGameThread();
		ClothTeleportCosineThresholdInRadOverride = FMath::Cos(FMath::DegreesToRadians(TeleportRotationThresholdOverride));