p.ConstraintLinearDampingScale

p.ConstraintLinearDampingScale

#Overview

name: p.ConstraintLinearDampingScale

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.ConstraintLinearDampingScale is to provide a multiplier for the linear damping of constraints in the physics simulation system of Unreal Engine 5. This setting variable allows developers to adjust the overall strength of linear damping applied to constraints, which affects how quickly linear motion is reduced in constrained physics objects.

This setting variable is primarily used by the physics engine subsystem within Unreal Engine 5, specifically in the constraint simulation component. Based on the callsites, it’s evident that this variable is utilized in the PhysicsEngine module, particularly in the ConstraintInstance and ConstraintTypes components.

The value of this variable is set as a console variable (CVar) with a default value of 1.0. It is defined as a TAutoConsoleVariable in the ConstraintInstance.cpp file, which means it can be adjusted at runtime through the console or configuration files.

The associated variable CVarConstraintLinearDampingScale interacts directly with p.ConstraintLinearDampingScale, as they share the same value. This CVar is used to access the value of the setting in the C++ code.

Developers should be aware that this variable is marked as ECVF_ReadOnly, which means it should not be modified during gameplay. Changes to this variable will affect all constraints in the simulation, so it should be used carefully to avoid unintended physics behavior.

Best practices when using this variable include:

  1. Use it for global adjustments to constraint damping, rather than for fine-tuning individual constraints.
  2. Test thoroughly after adjusting this value, as it can significantly impact the feel and stability of the physics simulation.
  3. Consider exposing this setting in a developer-only menu for easier tuning during development.

Regarding the associated variable CVarConstraintLinearDampingScale:

#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:22

Scope: file

Source code excerpt:


TAutoConsoleVariable<float> CVarConstraintLinearDampingScale(
	TEXT("p.ConstraintLinearDampingScale"),
	1.f,
	TEXT("The multiplier of constraint linear damping in simulation. Default: 1"),
	ECVF_ReadOnly);

TAutoConsoleVariable<float> CVarConstraintLinearStiffnessScale(
	TEXT("p.ConstraintLinearStiffnessScale"),

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

#define LOCTEXT_NAMESPACE "ConstraintInstance"

TAutoConsoleVariable<float> CVarConstraintLinearDampingScale(
	TEXT("p.ConstraintLinearDampingScale"),
	1.f,
	TEXT("The multiplier of constraint linear damping in simulation. Default: 1"),
	ECVF_ReadOnly);

TAutoConsoleVariable<float> CVarConstraintLinearStiffnessScale(

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

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:6

Scope: file

Source code excerpt:

#include UE_INLINE_GENERATED_CPP_BY_NAME(ConstraintTypes)

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)