p.Chaos.JointConstraint.LinaearDriveDampingScale

p.Chaos.JointConstraint.LinaearDriveDampingScale

#Overview

name: p.Chaos.JointConstraint.LinaearDriveDampingScale

This variable is created as a Console Variable (cvar).

It is referenced in 9 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.JointConstraint.LinaearDriveDampingScale is to provide a conversion factor for linear drive damping in the Chaos physics engine’s joint constraint system. This setting variable is used to scale the damping values applied to linear drives in joint constraints.

The Unreal Engine subsystem that relies on this setting variable is the Chaos physics engine, specifically its joint constraint system. This is part of the physics simulation module in Unreal Engine 5.

The value of this variable is set through a console variable (CVar) system, as seen in the ChaosConstraintSettings.cpp file. It’s initialized with a default value of 1.0f and can be adjusted at runtime through the console or configuration files.

This variable interacts closely with other joint constraint settings, particularly LinearDriveStiffnessScale, AngularDriveStiffnessScale, and AngularDriveDampingScale. These variables work together to control the behavior of joint constraints in the physics simulation.

Developers must be aware that changing this variable will affect the damping behavior of linear drives in joint constraints across the entire physics simulation. It’s a global scale factor, so it will impact all linear drive damping calculations unless overridden locally.

Best practices when using this variable include:

  1. Use it for global adjustments to linear drive damping behavior.
  2. Be cautious when modifying it, as it can significantly impact the feel and stability of physics simulations.
  3. Consider using it in conjunction with the other drive scale factors for a balanced adjustment of joint constraint behavior.
  4. Test thoroughly after making changes, as it can affect the entire physics simulation.

Regarding the associated variable LinearDriveDampingScale:

The purpose of LinearDriveDampingScale is the same as p.Chaos.JointConstraint.LinaearDriveDampingScale. They are essentially the same variable, with the former being the internal representation and the latter being the console variable name.

This variable is used in various parts of the physics engine to scale the damping values for linear drives in joint constraints. It’s applied when setting up joint constraints, updating linear drives, and in physical animation components.

The value is set through the console variable system and can be accessed through the Chaos::ConstraintSettings::LinearDriveDampingScale() function.

Developers should be aware that this scale is applied multiplicatively to the damping values specified in joint constraint profiles or drive parameters. Therefore, a value of 1.0 represents no scaling, while values greater than 1.0 increase damping and values less than 1.0 decrease damping.

Best practices include using this scale factor to fine-tune the overall feel of linear drive damping across the simulation, rather than adjusting individual constraint values, which can be more time-consuming and less consistent.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosConstraintSettings.cpp:28

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"));
		FAutoConsoleVariableRef CVarSoftAngularForceMode(TEXT("p.Chaos.JointConstraint.SoftAngularForceMode"), SoftAngularForceMode, TEXT("Soft Angular constraint force mode (0: Acceleration; 1: Force"));

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Experimental/PhysicsControl/Source/PhysicsControl/Private/RigidBodyWithControl.cpp:1028

Scope (from outer to inner):

file
function     void FAnimNode_RigidBodyWithControl::ApplyCurrentConstraintProfile

Source code excerpt:

							Profile.LinearDrive.YDrive.Stiffness, 
							Profile.LinearDrive.ZDrive.Stiffness);
					JointSettings.LinearDriveDamping = Chaos::ConstraintSettings::LinearDriveDampingScale() * FVec3(
							Profile.LinearDrive.XDrive.Damping, 
							Profile.LinearDrive.YDrive.Damping, 
							Profile.LinearDrive.ZDrive.Damping);
					JointSettings.LinearDriveMaxForce[0] = Profile.LinearDrive.XDrive.MaxForce;
					JointSettings.LinearDriveMaxForce[1] = Profile.LinearDrive.YDrive.MaxForce;
					JointSettings.LinearDriveMaxForce[2] = Profile.LinearDrive.ZDrive.MaxForce;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/Experimental/PhysInterface_Chaos.cpp:388

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));
		}
	}
}

void FPhysInterface_Chaos::UpdateAngularDrive_AssumesLocked(const FPhysicsConstraintHandle& InConstraintRef, const FAngularDriveConstraint& InDriveParams, bool InInitialize)

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ImmediatePhysics/ImmediatePhysicsChaos/ImmediatePhysicsJointHandle_Chaos.cpp:93

Scope (from outer to inner):

file
namespace    ImmediatePhysics_Chaos
function     void TransferJointSettings

Source code excerpt:

		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

		if (Profile.AngularDrive.AngularDriveMode == EAngularDriveMode::SLERP)

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/PhysicalAnimationComponent.cpp:321

Scope (from outer to inner):

file
function     void SetMotorStrength

Source code excerpt:


	PositionStrengthMultiplier *= Chaos::ConstraintSettings::LinearDriveStiffnessScale();
	VelocityStrengthMultiplier *= Chaos::ConstraintSettings::LinearDriveDampingScale();
	OrientationStrengthMultiplier *= Chaos::ConstraintSettings::AngularDriveStiffnessScale();
	AngularVelocityStrengthMultiplier *= Chaos::ConstraintSettings::AngularDriveDampingScale();

	ConstraintInstance.SetAngularDriveParams(
		PhysAnimData.OrientationStrength * OrientationStrengthMultiplier, 
		PhysAnimData.AngularVelocityStrength * AngularVelocityStrengthMultiplier,

#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosConstraintSettings.cpp:11

Scope (from outer to inner):

file
namespace    Chaos
namespace    JointConstraintDefaults

Source code excerpt:


		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;
		float SoftLinearDampingScale = 1.2f;

#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosConstraintSettings.cpp:28

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"));
		FAutoConsoleVariableRef CVarSoftAngularForceMode(TEXT("p.Chaos.JointConstraint.SoftAngularForceMode"), SoftAngularForceMode, TEXT("Soft Angular constraint force mode (0: Acceleration; 1: Force"));

#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Private/ChaosConstraintSettings.cpp:43

Scope (from outer to inner):

file
namespace    Chaos
function     FReal ConstraintSettings::LinearDriveDampingScale

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;}
	int ConstraintSettings::SoftAngularForceMode() { return JointConstraintDefaults::SoftAngularForceMode;}

#Loc: <Workspace>/Engine/Source/Runtime/PhysicsCore/Public/Chaos/ChaosConstraintSettings.h:19

Scope (from outer to inner):

file
namespace    Chaos
class        class ConstraintSettings

Source code excerpt:

		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();
		static PHYSICSCORE_API FReal SoftLinearDampingScale();