p.ConstraintLinearDampingScale
p.ConstraintLinearDampingScale
#Overview
name: p.ConstraintLinearDampingScale
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
The multiplier of constraint linear damping in simulation. Default: 1
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:
- Use it for global adjustments to constraint damping, rather than for fine-tuning individual constraints.
- Test thoroughly after adjusting this value, as it can significantly impact the feel and stability of the physics simulation.
- Consider exposing this setting in a developer-only menu for easier tuning during development.
Regarding the associated variable CVarConstraintLinearDampingScale:
- Its purpose is to provide programmatic access to the p.ConstraintLinearDampingScale value within the C++ code.
- It is used in the same PhysicsEngine subsystem, specifically in the ConstraintInstance and ConstraintTypes components.
- Its value is set automatically based on the p.ConstraintLinearDampingScale console variable.
- It interacts with other constraint-related variables, such as CVarConstraintAngularDampingScale, as seen in the PostSerialize function.
- Developers should be aware that this variable is used to retrieve the current value of the damping scale in the code, and any changes to the console variable will be reflected through this CVar.
- Best practices include using GetValueOnAnyThread() when accessing the value, as shown in the code examples, to ensure thread-safe access to the variable’s current value.
#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)