p.ConstraintAngularDampingScale

p.ConstraintAngularDampingScale

#Overview

name: p.ConstraintAngularDampingScale

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.ConstraintAngularDampingScale is to provide a multiplier for constraint angular damping in physics simulations within Unreal Engine 5. This setting variable is primarily used in the physics engine subsystem, specifically for constraint-based physics calculations.

The Unreal Engine subsystem that relies on this setting variable is the Physics Engine, particularly the constraint system within it. This can be seen from the file locations where the variable is referenced, such as “ConstraintInstance.cpp” and “ConstraintTypes.cpp”.

The value of this variable is set as a console variable with a default value of 100000.0. It’s defined using the TAutoConsoleVariable template, which allows it to be changed at runtime through console commands.

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

  1. CVarConstraintAngularStiffnessScale
  2. CVarConstraintLinearDampingScale
  3. CVarConstraintLinearStiffnessScale

Developers must be aware that this variable has a significant impact on the behavior of physics constraints in the engine. It directly affects the angular damping of constraints, which can influence the stability and realism of physics simulations.

Best practices when using this variable include:

  1. Carefully adjusting its value to achieve the desired physics behavior without introducing instability.
  2. Testing thoroughly after changes, as it can affect the entire physics simulation.
  3. Considering its interaction with other constraint-related variables for a holistic approach to physics tuning.

Regarding the associated variable CVarConstraintAngularDampingScale:

This is the actual console variable that stores and provides access to the p.ConstraintAngularDampingScale value. It’s defined using TAutoConsoleVariable, which allows for runtime modification of the value.

The purpose of CVarConstraintAngularDampingScale is to provide a programmatic interface to access and modify the p.ConstraintAngularDampingScale value within the C++ code of the engine.

This variable is used in various parts of the physics engine, particularly in the ConstraintInstance class. It’s used to scale angular damping values in physics calculations, such as in the PostSerialize function where it’s applied to various damping parameters.

Developers should be aware that changes to this variable will immediately affect the physics simulation. It’s marked as ECVF_ReadOnly, which means it can be set via console commands or configuration files, but not directly through code at runtime.

Best practices for using CVarConstraintAngularDampingScale include:

  1. Using GetValueOnAnyThread() to safely access its value from any thread.
  2. Considering its impact on physics performance and stability when modifying its value.
  3. Documenting any custom values used in project settings to ensure consistency across development and deployment environments.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ConstraintInstance.cpp:34

Scope: file

Source code excerpt:


TAutoConsoleVariable<float> CVarConstraintAngularDampingScale(
	TEXT("p.ConstraintAngularDampingScale"),
	100000.f,
	TEXT("The multiplier of constraint angular damping in simulation. Default: 100000"),
	ECVF_ReadOnly);

TAutoConsoleVariable<float> CVarConstraintAngularStiffnessScale(
	TEXT("p.ConstraintAngularStiffnessScale"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ConstraintInstance.cpp:33

Scope: file

Source code excerpt:

	ECVF_ReadOnly);

TAutoConsoleVariable<float> CVarConstraintAngularDampingScale(
	TEXT("p.ConstraintAngularDampingScale"),
	100000.f,
	TEXT("The multiplier of constraint angular damping in simulation. Default: 100000"),
	ECVF_ReadOnly);

TAutoConsoleVariable<float> CVarConstraintAngularStiffnessScale(

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ConstraintInstance.cpp:1166

Scope (from outer to inner):

file
function     void FConstraintInstance::PostSerialize

Source code excerpt:

		SwingLimitStiffness_DEPRECATED		/= CVarConstraintAngularStiffnessScale.GetValueOnAnyThread();
		TwistLimitStiffness_DEPRECATED		/= CVarConstraintAngularStiffnessScale.GetValueOnAnyThread();
		LinearLimitDamping_DEPRECATED		/=  CVarConstraintAngularDampingScale.GetValueOnAnyThread();
		SwingLimitDamping_DEPRECATED		/=  CVarConstraintAngularDampingScale.GetValueOnAnyThread();
		TwistLimitDamping_DEPRECATED		/=  CVarConstraintAngularDampingScale.GetValueOnAnyThread();
	}

	if (Ar.IsLoading() && Ar.UEVer() < VER_UE4_FIXUP_MOTOR_UNITS)
	{
		AngularVelocityTarget_DEPRECATED *= 1.f / (2.f * UE_PI);	//we want to use revolutions per second - old system was using radians directly
	}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ConstraintInstance.cpp:1287

Scope (from outer to inner):

file
function     void FConstraintInstance::PostSerialize

Source code excerpt:

		}

		if (CVarConstraintAngularDampingScale.GetValueOnAnyThread() > 0.f)
		{
			ProfileInstance.LinearLimit.Damping *= CVarConstraintAngularDampingScale.GetValueOnAnyThread() / CVarConstraintLinearDampingScale.GetValueOnAnyThread();
		}
	}
}
#endif

//Hacks to easily get zeroed memory for special case when we don't use GC

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ConstraintTypes.cpp:8

Scope: file

Source code excerpt:

extern TAutoConsoleVariable<float> CVarConstraintLinearDampingScale;
extern TAutoConsoleVariable<float> CVarConstraintLinearStiffnessScale;
extern TAutoConsoleVariable<float> CVarConstraintAngularDampingScale;
extern TAutoConsoleVariable<float> CVarConstraintAngularStiffnessScale;

/** Util for setting linear movement for an axis */
void SetLinearMovement_AssumesLocked(const FPhysicsConstraintHandle& InConstraintRef, PhysicsInterfaceTypes::ELimitAxis InAxis, ELinearConstraintMotion Motion, bool bLockLimitSize, bool bSkipSoftLimit)
{
	if(Motion == LCM_Locked || (Motion == LCM_Limited && bLockLimitSize))