p.Cloth.TeleportRotationThreshold

p.Cloth.TeleportRotationThreshold

#Overview

name: p.Cloth.TeleportRotationThreshold

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.TeleportRotationThreshold is to set a rotation threshold for cloth teleportation in Unreal Engine 5’s cloth simulation system. It determines when a cloth simulation should be reset due to large rotational changes in a single frame.

This setting variable is primarily used by the cloth simulation system, which is part of Unreal Engine’s physics module. The variable is defined and used in the SkeletalMeshComponentPhysics.cpp file, indicating its relevance to skeletal mesh components and their associated cloth simulations.

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

This variable interacts closely with other cloth-related variables, particularly:

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

These variables work together to determine when and how cloth simulations should be reset or “teleported” to maintain visual consistency and prevent unrealistic behavior.

Developers should be aware that:

  1. This threshold is in degrees, ranging from 0 to 180.
  2. The check is skipped if the value is zero or negative.
  3. It requires p.Cloth.TeleportOverride to be effective.

Best practices when using this variable include:

  1. Carefully tuning the value based on your game’s specific needs and the typical rotational velocities of your characters.
  2. Using it in conjunction with p.Cloth.TeleportDistanceThreshold for comprehensive teleportation criteria.
  3. Testing thoroughly to ensure cloth behavior remains visually pleasing across various gameplay scenarios.

Regarding the associated variable CVarClothTeleportRotationThreshold: This is the actual console variable that stores the value of p.Cloth.TeleportRotationThreshold. It’s used internally by the engine to access and modify the threshold value. The relationship between p.Cloth.TeleportRotationThreshold and CVarClothTeleportRotationThreshold is that of a console command and its corresponding variable.

When working with this variable programmatically, developers would typically interact with CVarClothTeleportRotationThreshold rather than directly with p.Cloth.TeleportRotationThreshold. The value can be retrieved using GetValueOnGameThread() method, as seen in the provided code excerpt.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:

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."));

//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);

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

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."));

//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);

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

Scope (from outer to inner):

file
function     void USkeletalMeshComponent::CheckClothTeleport

Source code excerpt:

		TeleportDistanceThresholdOverride = CVarClothTeleportDistanceThreshold.GetValueOnGameThread();
		ClothTeleportDistThresholdSquaredOverride = FMath::Square(TeleportDistanceThresholdOverride);
		TeleportRotationThresholdOverride = CVarClothTeleportRotationThreshold.GetValueOnGameThread();
		ClothTeleportCosineThresholdInRadOverride = FMath::Cos(FMath::DegreesToRadians(TeleportRotationThresholdOverride));
	}
	else
	{
		bResetAfterTeleportOverride = bResetAfterTeleport;
		TeleportDistanceThresholdOverride = TeleportDistanceThreshold;