p.Chaos.JointConstraint.SoftLinearForceMode
p.Chaos.JointConstraint.SoftLinearForceMode
#Overview
name: p.Chaos.JointConstraint.SoftLinearForceMode
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Soft Linear constraint force mode (0: Acceleration; 1: Force
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.JointConstraint.SoftLinearForceMode is to control the force mode for soft linear constraints in the Chaos physics engine of Unreal Engine 5. This setting variable is part of the joint constraint system within the physics simulation.
The Chaos physics engine, which is part of Unreal Engine’s physics core, relies on this setting variable. It is specifically used in the joint constraint subsystem to determine how soft linear constraints should be applied.
The value of this variable is set through a console variable (CVar) system. It is initialized with a default value of 0 (EJointForceMode::Acceleration) and can be changed at runtime.
This variable interacts closely with SoftLinearForceMode, which is an associated variable that shares the same value. It’s also related to other joint constraint settings like SoftAngularForceMode, SoftLinearStiffnessScale, and SoftLinearDampingScale.
Developers must be aware that this variable affects the behavior of soft linear constraints in physics simulations. A value of 0 means the constraint will use acceleration-based forces, while a value of 1 will use direct force application.
Best practices when using this variable include:
- Understanding the difference between acceleration-based and force-based constraint modes and their impact on simulation stability and performance.
- Considering the interaction with other joint constraint settings for a holistic approach to physics simulation.
- Testing different values in various scenarios to find the optimal setting for your specific use case.
Regarding the associated variable SoftLinearForceMode:
The purpose of SoftLinearForceMode is to provide a type-safe way to access the force mode setting within C++ code. It’s used in the same context as p.Chaos.JointConstraint.SoftLinearForceMode, determining how soft linear constraints are applied in the physics simulation.
This variable is typically used in the physics core and plugins that interact with the Chaos physics engine. It’s accessed through the Chaos::ConstraintSettings::SoftLinearForceMode() function.
The value of SoftLinearForceMode is set based on the console variable p.Chaos.JointConstraint.SoftLinearForceMode. It’s used to configure joint settings in various parts of the engine, such as in the RigidBodyWithControl and ImmediatePhysics systems.
Developers should be aware that changes to p.Chaos.JointConstraint.SoftLinearForceMode will directly affect SoftLinearForceMode. They should use the appropriate accessor functions when working with this setting in C++ code to ensure consistency and type safety.
Best practices include using the provided ConstraintSettings::SoftLinearForceMode() function to access this value, rather than directly accessing the console variable, to maintain proper encapsulation and allow for future changes to the underlying implementation.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosConstraintSettings.cpp:33
Scope (from outer to inner):
file
namespace Chaos
namespace JointConstraintDefaults
Source code excerpt:
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."));
FAutoConsoleVariableRef CVarJointAngularBreakScale(TEXT("p.Chaos.JointConstraint.AngularBreakScale"), AngularBreakScale, TEXT("Conversion factory for Angular Break Theshold."));
}
#Associated Variable and Callsites
This variable is associated with another variable named SoftLinearForceMode
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Experimental/PhysicsControl/Source/PhysicsControl/Private/RigidBodyWithControl.cpp:989
Scope (from outer to inner):
file
function void FAnimNode_RigidBodyWithControl::ApplyCurrentConstraintProfile
Source code excerpt:
JointSettings.bSoftSwingLimitsEnabled = Profile.ConeLimit.bSoftConstraint;
JointSettings.LinearSoftForceMode = (ConstraintSettings::SoftLinearForceMode() == 0) ?
EJointForceMode::Acceleration : EJointForceMode::Force;
JointSettings.AngularSoftForceMode = (ConstraintSettings::SoftAngularForceMode() == 0) ?
EJointForceMode::Acceleration : EJointForceMode::Force;
JointSettings.SoftLinearStiffness =
Chaos::ConstraintSettings::SoftLinearStiffnessScale() * Profile.LinearLimit.Stiffness;
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ImmediatePhysics/ImmediatePhysicsChaos/ImmediatePhysicsJointHandle_Chaos.cpp:65
Scope (from outer to inner):
file
namespace ImmediatePhysics_Chaos
function void TransferJointSettings
Source code excerpt:
ConstraintSettings.SoftSwingStiffness = Chaos::ConstraintSettings::SoftAngularStiffnessScale() * ConstraintInstance->GetSoftSwingLimitStiffness();
ConstraintSettings.SoftSwingDamping = Chaos::ConstraintSettings::SoftAngularDampingScale() * ConstraintInstance->GetSoftSwingLimitDamping();
ConstraintSettings.LinearSoftForceMode = (Chaos::ConstraintSettings::SoftLinearForceMode() == 0) ? EJointForceMode::Acceleration : EJointForceMode::Force;
ConstraintSettings.AngularSoftForceMode = (Chaos::ConstraintSettings::SoftAngularForceMode() == 0) ? EJointForceMode::Acceleration : EJointForceMode::Force;
if (!ConstraintSettings.bSoftLinearLimitsEnabled)
{
ConstraintSettings.LinearRestitution = Profile.LinearLimit.Restitution;
ConstraintSettings.LinearContactDistance = Profile.LinearLimit.ContactDistance;
#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosConstraintSettings.cpp:15
Scope (from outer to inner):
file
namespace Chaos
namespace JointConstraintDefaults
Source code excerpt:
float AngularDriveDampingScale = 1.5f;
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:33
Scope (from outer to inner):
file
namespace Chaos
namespace JointConstraintDefaults
Source code excerpt:
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."));
FAutoConsoleVariableRef CVarJointAngularBreakScale(TEXT("p.Chaos.JointConstraint.AngularBreakScale"), AngularBreakScale, TEXT("Conversion factory for Angular Break Theshold."));
}
#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosConstraintSettings.cpp:46
Scope (from outer to inner):
file
namespace Chaos
function int ConstraintSettings::SoftLinearForceMode
Source code excerpt:
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;}
int ConstraintSettings::SoftAngularForceMode() { return JointConstraintDefaults::SoftAngularForceMode;}
FReal ConstraintSettings::SoftAngularStiffnessScale() { return JointConstraintDefaults::SoftAngularStiffnessScale;}
FReal ConstraintSettings::SoftAngularDampingScale() { return JointConstraintDefaults::SoftAngularDampingScale;}
FReal ConstraintSettings::LinearBreakScale() { return JointConstraintDefaults::LinearBreakScale;}
#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Public/Chaos/ChaosConstraintSettings.h:23
Scope (from outer to inner):
file
namespace Chaos
class class ConstraintSettings
Source code excerpt:
static PHYSICSCORE_API FReal AngularDriveDampingScale();
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();