p.Chaos.JointConstraint.LinearDriveStiffnessScale
p.Chaos.JointConstraint.LinearDriveStiffnessScale
#Overview
name: p.Chaos.JointConstraint.LinearDriveStiffnessScale
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Conversion factor for Linear drive stiffness.
It is referenced in 9
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.JointConstraint.LinearDriveStiffnessScale is to serve as a conversion factor for linear drive stiffness in the Chaos physics system of Unreal Engine 5. This setting variable is primarily used in the physics simulation, specifically for joint constraints and their linear drive properties.
To address the remaining points:
-
Unreal Engine subsystems that rely on this variable: The Chaos physics system, which is part of the PhysicsCore module, heavily relies on this variable. It’s also used in the PhysicsControl plugin and the Engine module’s physics-related components.
-
Value setting: The value is initially set to 1.0f in the Chaos::JointConstraintDefaults namespace. It can be modified at runtime through the console variable system using the command “p.Chaos.JointConstraint.LinearDriveStiffnessScale”.
-
Interacting variables: This variable interacts with other joint constraint settings, such as LinearDriveDampingScale, AngularDriveStiffnessScale, and AngularDriveDampingScale. It’s often used in conjunction with these variables to fine-tune the behavior of joint constraints.
-
Special considerations: Developers should be aware that this variable acts as a scaling factor. Changing its value will affect the stiffness of linear drives in joint constraints across the entire physics simulation. It’s a global setting that can have wide-ranging effects on physics behavior.
-
Best practices:
- Use this variable cautiously, as it affects all linear drive stiffness calculations in the physics simulation.
- Test thoroughly after making changes to ensure desired physics behavior is maintained.
- Consider using it in conjunction with other related variables for a balanced adjustment of joint constraint properties.
Regarding the associated variable LinearDriveStiffnessScale:
This is actually the same variable, just accessed through different means. It’s defined in the Chaos::JointConstraintDefaults namespace and accessed via the Chaos::ConstraintSettings::LinearDriveStiffnessScale() function. This function is used throughout the codebase to apply the scaling factor to linear drive stiffness calculations in various physics-related components and systems.
The usage of this variable demonstrates how Unreal Engine 5’s Chaos physics system allows for global adjustment of physics properties, enabling developers to fine-tune the behavior of joint constraints across their entire game or simulation.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosConstraintSettings.cpp:27
Scope (from outer to inner):
file
namespace Chaos
namespace JointConstraintDefaults
Source code excerpt:
FAutoConsoleVariableRef CVarJointStiffness(TEXT("p.Chaos.JointConstraint.JointStiffness"), JointStiffness, TEXT("Hard-joint solver stiffness."));
FAutoConsoleVariableRef CVarLinearDriveStiffnessScale(TEXT("p.Chaos.JointConstraint.LinearDriveStiffnessScale"), LinearDriveStiffnessScale, TEXT("Conversion factor for Linear drive stiffness."));
FAutoConsoleVariableRef CVarLinearDriveDampingScale(TEXT("p.Chaos.JointConstraint.LinaearDriveDampingScale"), LinearDriveDampingScale, TEXT("Conversion factor for Linear drive damping."));
FAutoConsoleVariableRef CVarAngularDriveStiffnessScale(TEXT("p.Chaos.JointConstraint.AngularDriveStiffnessScale"), AngularDriveStiffnessScale, TEXT("Conversion factor for Angular drive stiffness."));
FAutoConsoleVariableRef CVarAngularDriveDampingScale(TEXT("p.Chaos.JointConstraint.AngularDriveDampingScale"), AngularDriveDampingScale, TEXT("Conversion factor for Angular drive damping."));
FAutoConsoleVariableRef CVarSoftLinearStiffnessScale(TEXT("p.Chaos.JointConstraint.SoftLinearStiffnessScale"), SoftLinearStiffnessScale, TEXT("Conversion factor for soft-joint stiffness."));
FAutoConsoleVariableRef CVarSoftLinearDampingScale(TEXT("p.Chaos.JointConstraint.SoftLinearDampingScale"), SoftLinearDampingScale, TEXT("Conversion factor for soft-joint damping."));
FAutoConsoleVariableRef CVarSoftLinearForceMode(TEXT("p.Chaos.JointConstraint.SoftLinearForceMode"), SoftLinearForceMode, TEXT("Soft Linear constraint force mode (0: Acceleration; 1: Force"));
#Associated Variable and Callsites
This variable is associated with another variable named LinearDriveStiffnessScale
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Experimental/PhysicsControl/Source/PhysicsControl/Private/RigidBodyWithControl.cpp:1024
Scope (from outer to inner):
file
function void FAnimNode_RigidBodyWithControl::ApplyCurrentConstraintProfile
Source code excerpt:
JointSettings.bLinearVelocityDriveEnabled[2] = Profile.LinearDrive.ZDrive.bEnableVelocityDrive;
JointSettings.LinearDriveForceMode = EJointForceMode::Acceleration; // hardcoded!
JointSettings.LinearDriveStiffness = Chaos::ConstraintSettings::LinearDriveStiffnessScale() * FVec3(
Profile.LinearDrive.XDrive.Stiffness,
Profile.LinearDrive.YDrive.Stiffness,
Profile.LinearDrive.ZDrive.Stiffness);
JointSettings.LinearDriveDamping = Chaos::ConstraintSettings::LinearDriveDampingScale() * FVec3(
Profile.LinearDrive.XDrive.Damping,
Profile.LinearDrive.YDrive.Damping,
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/Experimental/PhysInterface_Chaos.cpp:387
Scope (from outer to inner):
file
function void FPhysInterface_Chaos::UpdateLinearDrive_AssumesLocked
Source code excerpt:
Constraint->SetLinearDriveForceMode(Chaos::EJointForceMode::Acceleration);
Constraint->SetLinearDriveStiffness(Chaos::ConstraintSettings::LinearDriveStiffnessScale() * Chaos::FVec3(InDriveParams.XDrive.Stiffness, InDriveParams.YDrive.Stiffness, InDriveParams.ZDrive.Stiffness));
Constraint->SetLinearDriveDamping(Chaos::ConstraintSettings::LinearDriveDampingScale() * Chaos::FVec3(InDriveParams.XDrive.Damping, InDriveParams.YDrive.Damping, InDriveParams.ZDrive.Damping));
Constraint->SetLinearDriveMaxForce(Chaos::FVec3(InDriveParams.XDrive.MaxForce, InDriveParams.YDrive.MaxForce, InDriveParams.ZDrive.MaxForce));
}
}
}
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ImmediatePhysics/ImmediatePhysicsChaos/ImmediatePhysicsJointHandle_Chaos.cpp:92
Scope (from outer to inner):
file
namespace ImmediatePhysics_Chaos
function void TransferJointSettings
Source code excerpt:
ConstraintSettings.bLinearVelocityDriveEnabled[1] = Profile.LinearDrive.YDrive.bEnableVelocityDrive;
ConstraintSettings.bLinearVelocityDriveEnabled[2] = Profile.LinearDrive.ZDrive.bEnableVelocityDrive;
ConstraintSettings.LinearDriveStiffness = Chaos::ConstraintSettings::LinearDriveStiffnessScale() * Chaos::FVec3(Profile.LinearDrive.XDrive.Stiffness, Profile.LinearDrive.YDrive.Stiffness, Profile.LinearDrive.ZDrive.Stiffness);
ConstraintSettings.LinearDriveDamping = Chaos::ConstraintSettings::LinearDriveDampingScale() * Chaos::FVec3(Profile.LinearDrive.XDrive.Damping, Profile.LinearDrive.YDrive.Damping, Profile.LinearDrive.ZDrive.Damping);
ConstraintSettings.LinearDriveForceMode = EJointForceMode::Acceleration;
ConstraintSettings.AngularDrivePositionTarget = FQuat(Profile.AngularDrive.OrientationTarget);
ConstraintSettings.AngularDriveVelocityTarget = Profile.AngularDrive.AngularVelocityTarget * 2.0f * UE_PI; // Rev/s to Rad/s
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/PhysicalAnimationComponent.cpp:320
Scope (from outer to inner):
file
function void SetMotorStrength
Source code excerpt:
float AngularVelocityStrengthMultiplier = StrengthMultiplier;
PositionStrengthMultiplier *= Chaos::ConstraintSettings::LinearDriveStiffnessScale();
VelocityStrengthMultiplier *= Chaos::ConstraintSettings::LinearDriveDampingScale();
OrientationStrengthMultiplier *= Chaos::ConstraintSettings::AngularDriveStiffnessScale();
AngularVelocityStrengthMultiplier *= Chaos::ConstraintSettings::AngularDriveDampingScale();
ConstraintInstance.SetAngularDriveParams(
PhysAnimData.OrientationStrength * OrientationStrengthMultiplier,
#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosConstraintSettings.cpp:10
Scope (from outer to inner):
file
namespace Chaos
namespace JointConstraintDefaults
Source code excerpt:
float JointStiffness = 1.0f;
float LinearDriveStiffnessScale = 1.0f;
float LinearDriveDampingScale = 1.0f;
float AngularDriveStiffnessScale = 1.5f;
float AngularDriveDampingScale = 1.5f;
int SoftLinearForceMode = (int)EJointForceMode::Acceleration;
float SoftLinearStiffnessScale = 1.5f;
#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosConstraintSettings.cpp:27
Scope (from outer to inner):
file
namespace Chaos
namespace JointConstraintDefaults
Source code excerpt:
FAutoConsoleVariableRef CVarJointStiffness(TEXT("p.Chaos.JointConstraint.JointStiffness"), JointStiffness, TEXT("Hard-joint solver stiffness."));
FAutoConsoleVariableRef CVarLinearDriveStiffnessScale(TEXT("p.Chaos.JointConstraint.LinearDriveStiffnessScale"), LinearDriveStiffnessScale, TEXT("Conversion factor for Linear drive stiffness."));
FAutoConsoleVariableRef CVarLinearDriveDampingScale(TEXT("p.Chaos.JointConstraint.LinaearDriveDampingScale"), LinearDriveDampingScale, TEXT("Conversion factor for Linear drive damping."));
FAutoConsoleVariableRef CVarAngularDriveStiffnessScale(TEXT("p.Chaos.JointConstraint.AngularDriveStiffnessScale"), AngularDriveStiffnessScale, TEXT("Conversion factor for Angular drive stiffness."));
FAutoConsoleVariableRef CVarAngularDriveDampingScale(TEXT("p.Chaos.JointConstraint.AngularDriveDampingScale"), AngularDriveDampingScale, TEXT("Conversion factor for Angular drive damping."));
FAutoConsoleVariableRef CVarSoftLinearStiffnessScale(TEXT("p.Chaos.JointConstraint.SoftLinearStiffnessScale"), SoftLinearStiffnessScale, TEXT("Conversion factor for soft-joint stiffness."));
FAutoConsoleVariableRef CVarSoftLinearDampingScale(TEXT("p.Chaos.JointConstraint.SoftLinearDampingScale"), SoftLinearDampingScale, TEXT("Conversion factor for soft-joint damping."));
FAutoConsoleVariableRef CVarSoftLinearForceMode(TEXT("p.Chaos.JointConstraint.SoftLinearForceMode"), SoftLinearForceMode, TEXT("Soft Linear constraint force mode (0: Acceleration; 1: Force"));
#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosConstraintSettings.cpp:42
Scope (from outer to inner):
file
namespace Chaos
function FReal ConstraintSettings::LinearDriveStiffnessScale
Source code excerpt:
FReal ConstraintSettings::JointStiffness() { return JointConstraintDefaults::JointStiffness;}
FReal ConstraintSettings::LinearDriveStiffnessScale() { return JointConstraintDefaults::LinearDriveStiffnessScale;}
FReal ConstraintSettings::LinearDriveDampingScale() { return JointConstraintDefaults::LinearDriveDampingScale;}
FReal ConstraintSettings::AngularDriveStiffnessScale() { return JointConstraintDefaults::AngularDriveStiffnessScale;}
FReal ConstraintSettings::AngularDriveDampingScale() { return JointConstraintDefaults::AngularDriveDampingScale;}
int ConstraintSettings::SoftLinearForceMode() { return JointConstraintDefaults::SoftLinearForceMode;}
FReal ConstraintSettings::SoftLinearStiffnessScale() { return JointConstraintDefaults::SoftLinearStiffnessScale;}
FReal ConstraintSettings::SoftLinearDampingScale() { return JointConstraintDefaults::SoftLinearDampingScale;}
#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Public/Chaos/ChaosConstraintSettings.h:18
Scope (from outer to inner):
file
namespace Chaos
class class ConstraintSettings
Source code excerpt:
public:
static PHYSICSCORE_API FReal JointStiffness();
static PHYSICSCORE_API FReal LinearDriveStiffnessScale();
static PHYSICSCORE_API FReal LinearDriveDampingScale();
static PHYSICSCORE_API FReal AngularDriveStiffnessScale();
static PHYSICSCORE_API FReal AngularDriveDampingScale();
static PHYSICSCORE_API int SoftLinearForceMode();
static PHYSICSCORE_API FReal SoftLinearStiffnessScale();