p.Chaos.JointConstraint.SoftLinearStiffnessScale
p.Chaos.JointConstraint.SoftLinearStiffnessScale
#Overview
name: p.Chaos.JointConstraint.SoftLinearStiffnessScale
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Conversion factor for soft-joint stiffness.
It is referenced in 8
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.JointConstraint.SoftLinearStiffnessScale is to act as a conversion factor for soft-joint stiffness in the Chaos physics system of Unreal Engine 5. This setting variable is specifically used for joint constraints in the physics simulation.
This variable is primarily used in the Chaos physics subsystem, which is part of the PhysicsCore module in Unreal Engine 5. It’s also utilized in the PhysicsControl plugin and the Engine module’s physics-related components.
The value of this variable is set as a console variable (CVar) in the Chaos namespace, specifically in the JointConstraintDefaults namespace. It’s initialized with a default value of 1.5f and can be adjusted at runtime through the console or configuration files.
The SoftLinearStiffnessScale interacts with several other variables, particularly those related to joint constraints. It’s often used in conjunction with SoftLinearDampingScale, SoftAngularStiffnessScale, and SoftAngularDampingScale to define the behavior of soft constraints in the physics simulation.
Developers should be aware that this variable acts as a scaling factor. When applying soft linear stiffness to a joint, the actual stiffness value is multiplied by this scale. This allows for easy global adjustment of soft joint behavior without modifying individual joint settings.
Best practices when using this variable include:
- Adjusting it carefully, as it affects all soft linear joint constraints in the simulation.
- Using it in conjunction with other joint constraint settings for fine-tuned physics behavior.
- Testing thoroughly after modifying this value, as it can significantly impact the feel and stability of the physics simulation.
Regarding the associated variable SoftLinearStiffnessScale:
This is the actual variable that stores the value set by the p.Chaos.JointConstraint.SoftLinearStiffnessScale CVar. It serves the same purpose as described above, acting as a conversion factor for soft-joint stiffness.
It’s used in various parts of the physics system, including:
- The RigidBodyWithControl component in the PhysicsControl plugin
- The PhysInterface_Chaos in the Engine module
- The ImmediatePhysics system in the Engine module
The value of this variable is accessed through the ConstraintSettings::SoftLinearStiffnessScale() function, which returns the value stored in JointConstraintDefaults::SoftLinearStiffnessScale.
When working with this variable, developers should remember that it’s a static member of the ConstraintSettings class, meaning it affects all instances where it’s used. Any changes to this value will have a global effect on the physics simulation’s soft linear joint constraints.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosConstraintSettings.cpp:31
Scope (from outer to inner):
file
namespace Chaos
namespace JointConstraintDefaults
Source code excerpt:
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"));
FAutoConsoleVariableRef CVarSoftAngularForceMode(TEXT("p.Chaos.JointConstraint.SoftAngularForceMode"), SoftAngularForceMode, TEXT("Soft Angular constraint force mode (0: Acceleration; 1: Force"));
FAutoConsoleVariableRef CVarSoftAngularStiffnessScale(TEXT("p.Chaos.JointConstraint.SoftAngularStiffnessScale"), SoftAngularStiffnessScale, TEXT("Conversion factor for soft-joint stiffness."));
FAutoConsoleVariableRef CVarSoftAngularDampingScale(TEXT("p.Chaos.JointConstraint.SoftAngularDampingScale"), SoftAngularDampingScale, TEXT("Conversion factor for soft-joint damping."));
FAutoConsoleVariableRef CVarJointLinearBreakScale(TEXT("p.Chaos.JointConstraint.LinearBreakScale"), LinearBreakScale, TEXT("Conversion factory for Linear Break Theshold."));
#Associated Variable and Callsites
This variable is associated with another variable named SoftLinearStiffnessScale
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Experimental/PhysicsControl/Source/PhysicsControl/Private/RigidBodyWithControl.cpp:995
Scope (from outer to inner):
file
function void FAnimNode_RigidBodyWithControl::ApplyCurrentConstraintProfile
Source code excerpt:
JointSettings.SoftLinearStiffness =
Chaos::ConstraintSettings::SoftLinearStiffnessScale() * Profile.LinearLimit.Stiffness;
JointSettings.SoftLinearDamping =
Chaos::ConstraintSettings::SoftLinearDampingScale() * Profile.LinearLimit.Damping;
JointSettings.SoftTwistStiffness =
Chaos::ConstraintSettings::SoftAngularStiffnessScale() * Profile.TwistLimit.Stiffness;
JointSettings.SoftTwistDamping =
Chaos::ConstraintSettings::SoftAngularDampingScale() * Profile.TwistLimit.Damping;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/Experimental/PhysInterface_Chaos.cpp:300
Scope (from outer to inner):
file
function void FPhysInterface_Chaos::UpdateLinearLimitParams_AssumesLocked
Source code excerpt:
Constraint->SetSoftLinearLimitsEnabled(InParams.bSoftConstraint);
Constraint->SetSoftLinearStiffness(Chaos::ConstraintSettings::SoftLinearStiffnessScale() * InParams.Stiffness);
Constraint->SetSoftLinearDamping(Chaos::ConstraintSettings::SoftLinearDampingScale() * InParams.Damping);
Constraint->SetLinearContactDistance(InParams.ContactDistance);
Constraint->SetLinearRestitution(InParams.Restitution);
//Constraint->SetAngularSoftForceMode( InParams.NOT_QUITE_SURE ); // @todo(chaos)
}
}
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ImmediatePhysics/ImmediatePhysicsChaos/ImmediatePhysicsJointHandle_Chaos.cpp:59
Scope (from outer to inner):
file
namespace ImmediatePhysics_Chaos
function void TransferJointSettings
Source code excerpt:
ConstraintSettings.bSoftTwistLimitsEnabled = ConstraintInstance->GetIsSoftTwistLimit();
ConstraintSettings.bSoftSwingLimitsEnabled = ConstraintInstance->GetIsSoftSwingLimit();
ConstraintSettings.SoftLinearStiffness = Chaos::ConstraintSettings::SoftLinearStiffnessScale() * ConstraintInstance->GetSoftLinearLimitStiffness();
ConstraintSettings.SoftLinearDamping = Chaos::ConstraintSettings::SoftLinearDampingScale() * ConstraintInstance->GetSoftLinearLimitDamping();
ConstraintSettings.SoftTwistStiffness = Chaos::ConstraintSettings::SoftAngularStiffnessScale() * ConstraintInstance->GetSoftTwistLimitStiffness();
ConstraintSettings.SoftTwistDamping = Chaos::ConstraintSettings::SoftAngularDampingScale() * ConstraintInstance->GetSoftTwistLimitDamping();
ConstraintSettings.SoftSwingStiffness = Chaos::ConstraintSettings::SoftAngularStiffnessScale() * ConstraintInstance->GetSoftSwingLimitStiffness();
ConstraintSettings.SoftSwingDamping = Chaos::ConstraintSettings::SoftAngularDampingScale() * ConstraintInstance->GetSoftSwingLimitDamping();
ConstraintSettings.LinearSoftForceMode = (Chaos::ConstraintSettings::SoftLinearForceMode() == 0) ? EJointForceMode::Acceleration : EJointForceMode::Force;
#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosConstraintSettings.cpp:16
Scope (from outer to inner):
file
namespace Chaos
namespace JointConstraintDefaults
Source code excerpt:
int SoftLinearForceMode = (int)EJointForceMode::Acceleration;
float SoftLinearStiffnessScale = 1.5f;
float SoftLinearDampingScale = 1.2f;
int SoftAngularForceMode = (int)EJointForceMode::Acceleration;
float SoftAngularStiffnessScale = 100000;
float SoftAngularDampingScale = 1000;
#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosConstraintSettings.cpp:31
Scope (from outer to inner):
file
namespace Chaos
namespace JointConstraintDefaults
Source code excerpt:
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"));
FAutoConsoleVariableRef CVarSoftAngularForceMode(TEXT("p.Chaos.JointConstraint.SoftAngularForceMode"), SoftAngularForceMode, TEXT("Soft Angular constraint force mode (0: Acceleration; 1: Force"));
FAutoConsoleVariableRef CVarSoftAngularStiffnessScale(TEXT("p.Chaos.JointConstraint.SoftAngularStiffnessScale"), SoftAngularStiffnessScale, TEXT("Conversion factor for soft-joint stiffness."));
FAutoConsoleVariableRef CVarSoftAngularDampingScale(TEXT("p.Chaos.JointConstraint.SoftAngularDampingScale"), SoftAngularDampingScale, TEXT("Conversion factor for soft-joint damping."));
FAutoConsoleVariableRef CVarJointLinearBreakScale(TEXT("p.Chaos.JointConstraint.LinearBreakScale"), LinearBreakScale, TEXT("Conversion factory for Linear Break Theshold."));
#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosConstraintSettings.cpp:47
Scope (from outer to inner):
file
namespace Chaos
function FReal ConstraintSettings::SoftLinearStiffnessScale
Source code excerpt:
FReal ConstraintSettings::AngularDriveDampingScale() { return JointConstraintDefaults::AngularDriveDampingScale;}
int ConstraintSettings::SoftLinearForceMode() { return JointConstraintDefaults::SoftLinearForceMode;}
FReal ConstraintSettings::SoftLinearStiffnessScale() { return JointConstraintDefaults::SoftLinearStiffnessScale;}
FReal ConstraintSettings::SoftLinearDampingScale() { return JointConstraintDefaults::SoftLinearDampingScale;}
int ConstraintSettings::SoftAngularForceMode() { return JointConstraintDefaults::SoftAngularForceMode;}
FReal ConstraintSettings::SoftAngularStiffnessScale() { return JointConstraintDefaults::SoftAngularStiffnessScale;}
FReal ConstraintSettings::SoftAngularDampingScale() { return JointConstraintDefaults::SoftAngularDampingScale;}
FReal ConstraintSettings::LinearBreakScale() { return JointConstraintDefaults::LinearBreakScale;}
FReal ConstraintSettings::AngularBreakScale() { return JointConstraintDefaults::AngularBreakScale;}
#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Public/Chaos/ChaosConstraintSettings.h:24
Scope (from outer to inner):
file
namespace Chaos
class class ConstraintSettings
Source code excerpt:
static PHYSICSCORE_API int SoftLinearForceMode();
static PHYSICSCORE_API FReal SoftLinearStiffnessScale();
static PHYSICSCORE_API FReal SoftLinearDampingScale();
static PHYSICSCORE_API int SoftAngularForceMode();
static PHYSICSCORE_API FReal SoftAngularStiffnessScale();
static PHYSICSCORE_API FReal SoftAngularDampingScale();