p.Chaos.JointConstraint.AngularDriveStiffnessScale

p.Chaos.JointConstraint.AngularDriveStiffnessScale

#Overview

name: p.Chaos.JointConstraint.AngularDriveStiffnessScale

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

It is referenced in 10 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.JointConstraint.AngularDriveStiffnessScale is to provide a conversion factor for angular drive stiffness in joint constraints within the Chaos physics system of Unreal Engine 5. This setting variable is used to scale the stiffness of angular drives in physics simulations, allowing developers to fine-tune the behavior of joint constraints.

The Chaos physics system, which is part of Unreal Engine’s physics module, relies on this setting variable. It is primarily used in the PhysicsCore and Engine modules, as well as in some experimental plugins like PhysicsControl.

The value of this variable is set through a console variable (CVar) system, which allows it to be adjusted at runtime. It is initialized with a default value of 1.5f in the ChaosConstraintSettings.cpp file.

This variable interacts closely with other joint constraint settings, particularly:

  1. AngularDriveDampingScale
  2. LinearDriveStiffnessScale
  3. LinearDriveDampingScale

Developers should be aware that this variable directly affects the behavior of physics simulations, particularly in scenarios involving joint constraints and angular drives. Adjusting this value will change how stiffly angular drives respond in the simulation.

Best practices when using this variable include:

  1. Testing different values to find the optimal balance for your specific use case.
  2. Considering the interplay between stiffness and damping when adjusting this value.
  3. Being cautious when making large changes, as it can significantly impact simulation stability.

The associated variable AngularDriveStiffnessScale serves the same purpose and is used interchangeably with p.Chaos.JointConstraint.AngularDriveStiffnessScale. It is a static member of the Chaos::ConstraintSettings class and provides a way to access the same value through C++ code. This allows developers to use the scaled stiffness value in their physics calculations without directly accessing the console variable.

When working with AngularDriveStiffnessScale, developers should follow the same best practices and be aware of the same considerations as mentioned for p.Chaos.JointConstraint.AngularDriveStiffnessScale. The two variables are essentially different interfaces to the same underlying setting, one through the console variable system and the other through C++ code.

#References in C++ code

#Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    JointConstraintDefaults

Source code excerpt:

		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"));
		FAutoConsoleVariableRef CVarSoftAngularStiffnessScale(TEXT("p.Chaos.JointConstraint.SoftAngularStiffnessScale"), SoftAngularStiffnessScale, TEXT("Conversion factor for soft-joint stiffness."));

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
function     void FAnimNode_RigidBodyWithControl::ApplyCurrentConstraintProfile

Source code excerpt:

					{
						JointSettings.AngularDriveStiffness = FVec3(
							ConstraintSettings::AngularDriveStiffnessScale() * Profile.AngularDrive.SlerpDrive.Stiffness);
						JointSettings.AngularDriveDamping = FVec3(
							ConstraintSettings::AngularDriveDampingScale() * Profile.AngularDrive.SlerpDrive.Damping);
						JointSettings.AngularDriveMaxTorque = FVec3(
							Profile.AngularDrive.SlerpDrive.MaxForce);
						JointSettings.bAngularSLerpPositionDriveEnabled = Profile.AngularDrive.SlerpDrive.bEnablePositionDrive;
						JointSettings.bAngularSLerpVelocityDriveEnabled = Profile.AngularDrive.SlerpDrive.bEnableVelocityDrive;

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

Scope (from outer to inner):

file
function     void FAnimNode_RigidBodyWithControl::ApplyCurrentConstraintProfile

Source code excerpt:

					else
					{
						JointSettings.AngularDriveStiffness = ConstraintSettings::AngularDriveStiffnessScale() * FVec3(
							Profile.AngularDrive.TwistDrive.Stiffness, 
							Profile.AngularDrive.SwingDrive.Stiffness, 
							Profile.AngularDrive.SwingDrive.Stiffness);
						JointSettings.AngularDriveDamping = ConstraintSettings::AngularDriveDampingScale() * FVec3(
							Profile.AngularDrive.TwistDrive.Damping, 
							Profile.AngularDrive.SwingDrive.Damping, 

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

Scope (from outer to inner):

file
function     void FPhysInterface_Chaos::UpdateAngularDrive_AssumesLocked

Source code excerpt:

			if (InDriveParams.AngularDriveMode == EAngularDriveMode::TwistAndSwing)
			{
				Constraint->SetAngularDriveStiffness(Chaos::ConstraintSettings::AngularDriveStiffnessScale() * Chaos::FVec3(InDriveParams.TwistDrive.Stiffness, InDriveParams.SwingDrive.Stiffness, InDriveParams.SwingDrive.Stiffness));
				Constraint->SetAngularDriveDamping(Chaos::ConstraintSettings::AngularDriveDampingScale() * Chaos::FVec3(InDriveParams.TwistDrive.Damping, InDriveParams.SwingDrive.Damping, InDriveParams.SwingDrive.Damping));
				Constraint->SetAngularDriveMaxTorque(Chaos::FVec3(InDriveParams.TwistDrive.MaxForce, InDriveParams.SwingDrive.MaxForce, InDriveParams.SwingDrive.MaxForce));
			}
			else
			{
				Constraint->SetAngularDriveStiffness(Chaos::ConstraintSettings::AngularDriveStiffnessScale() * Chaos::FVec3(InDriveParams.SlerpDrive.Stiffness));
				Constraint->SetAngularDriveDamping(Chaos::ConstraintSettings::AngularDriveDampingScale() * Chaos::FVec3(InDriveParams.SlerpDrive.Damping));
				Constraint->SetAngularDriveMaxTorque(Chaos::FVec3(InDriveParams.TwistDrive.MaxForce, InDriveParams.SwingDrive.MaxForce, InDriveParams.SwingDrive.MaxForce));
			}
		}
	}
}

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

Scope (from outer to inner):

file
namespace    ImmediatePhysics_Chaos
function     void TransferJointSettings

Source code excerpt:

		if (Profile.AngularDrive.AngularDriveMode == EAngularDriveMode::SLERP)
		{
			ConstraintSettings.AngularDriveStiffness = Chaos::ConstraintSettings::AngularDriveStiffnessScale() * FVec3(Profile.AngularDrive.SlerpDrive.Stiffness);
			ConstraintSettings.AngularDriveDamping = Chaos::ConstraintSettings::AngularDriveDampingScale() * FVec3(Profile.AngularDrive.SlerpDrive.Damping);
			ConstraintSettings.bAngularSLerpPositionDriveEnabled = Profile.AngularDrive.SlerpDrive.bEnablePositionDrive;
			ConstraintSettings.bAngularSLerpVelocityDriveEnabled = Profile.AngularDrive.SlerpDrive.bEnableVelocityDrive;
		}
		else
		{
			ConstraintSettings.AngularDriveStiffness = Chaos::ConstraintSettings::AngularDriveStiffnessScale() * FVec3(Profile.AngularDrive.TwistDrive.Stiffness, Profile.AngularDrive.SwingDrive.Stiffness, Profile.AngularDrive.SwingDrive.Stiffness);
			ConstraintSettings.AngularDriveDamping = Chaos::ConstraintSettings::AngularDriveDampingScale() * FVec3(Profile.AngularDrive.TwistDrive.Damping, Profile.AngularDrive.SwingDrive.Damping, Profile.AngularDrive.SwingDrive.Damping);
			ConstraintSettings.bAngularTwistPositionDriveEnabled = Profile.AngularDrive.TwistDrive.bEnablePositionDrive;
			ConstraintSettings.bAngularTwistVelocityDriveEnabled = Profile.AngularDrive.TwistDrive.bEnableVelocityDrive;
			ConstraintSettings.bAngularSwingPositionDriveEnabled = Profile.AngularDrive.SwingDrive.bEnablePositionDrive;
			ConstraintSettings.bAngularSwingVelocityDriveEnabled = Profile.AngularDrive.SwingDrive.bEnableVelocityDrive;
		}

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

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,
		PhysAnimData.MaxAngularForce * StrengthMultiplier

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

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:29

Scope (from outer to inner):

file
namespace    Chaos
namespace    JointConstraintDefaults

Source code excerpt:

		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"));
		FAutoConsoleVariableRef CVarSoftAngularStiffnessScale(TEXT("p.Chaos.JointConstraint.SoftAngularStiffnessScale"), SoftAngularStiffnessScale, TEXT("Conversion factor for soft-joint stiffness."));

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

Scope (from outer to inner):

file
namespace    Chaos
function     FReal ConstraintSettings::AngularDriveStiffnessScale

Source code excerpt:

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

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

Scope (from outer to inner):

file
namespace    Chaos
class        class ConstraintSettings

Source code excerpt:

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