p.Chaos.JointConstraint.SoftAngularDampingScale

p.Chaos.JointConstraint.SoftAngularDampingScale

#Overview

name: p.Chaos.JointConstraint.SoftAngularDampingScale

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.SoftAngularDampingScale is to provide a conversion factor for soft-joint damping in the Chaos physics system of Unreal Engine 5. This setting variable is primarily used in the physics simulation, specifically for joint constraints in the Chaos physics engine.

The Chaos physics engine, which is part of Unreal Engine’s physics system, relies on this setting variable. It is used in various modules and plugins related to physics simulation, including the PhysicsCore, Engine, and PhysicsControl modules.

The value of this variable is set using an FAutoConsoleVariableRef in the ChaosConstraintSettings.cpp file. It is initialized with a default value of 1000 and can be modified at runtime through the console.

This variable interacts closely with other joint constraint settings, particularly SoftAngularStiffnessScale. They are often used together to define the behavior of soft joint constraints.

Developers must be aware that this variable acts as a scaling factor. It’s used to convert user-friendly damping values into the actual values used by the physics simulation. Changes to this scale can significantly affect the behavior of soft joint constraints in the physics simulation.

Best practices when using this variable include:

  1. Carefully consider any changes to this scale, as it will affect all soft joint constraints in the simulation.
  2. If adjusting this value, also consider adjusting the SoftAngularStiffnessScale to maintain the desired joint behavior.
  3. Use this in conjunction with per-joint damping settings for fine-tuned control.

Regarding the associated variable SoftAngularDampingScale:

The purpose of SoftAngularDampingScale is the same as p.Chaos.JointConstraint.SoftAngularDampingScale. They are essentially the same variable, with one being the console variable and the other being the C++ accessor.

This variable is used in various parts of the physics simulation, including the RigidBodyWithControl, PhysInterface_Chaos, and ImmediatePhysicsJointHandle_Chaos.

The value is set through the console variable and accessed via the ConstraintSettings::SoftAngularDampingScale() function.

It interacts closely with SoftAngularStiffnessScale and is often used in conjunction with it to define soft constraint behaviors.

Developers should be aware that this scale is applied to the damping values specified for individual joints. Changes to this global scale will affect all soft angular joint constraints in the simulation.

Best practices include using this scale in conjunction with per-joint damping settings for precise control over joint behavior, and considering the interplay between damping and stiffness when adjusting these scales.

#References in C++ code

#Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    JointConstraintDefaults

Source code excerpt:

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

	FReal ConstraintSettings::JointStiffness() { return JointConstraintDefaults::JointStiffness;}
	FReal ConstraintSettings::LinearDriveStiffnessScale() { return JointConstraintDefaults::LinearDriveStiffnessScale;}

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
function     void FAnimNode_RigidBodyWithControl::ApplyCurrentConstraintProfile

Source code excerpt:

						Chaos::ConstraintSettings::SoftAngularStiffnessScale() * Profile.TwistLimit.Stiffness;
					JointSettings.SoftTwistDamping = 
						Chaos::ConstraintSettings::SoftAngularDampingScale() * Profile.TwistLimit.Damping;
					JointSettings.SoftSwingStiffness = 
						Chaos::ConstraintSettings::SoftAngularStiffnessScale() * Profile.ConeLimit.Stiffness;
					JointSettings.SoftSwingDamping = 
						Chaos::ConstraintSettings::SoftAngularDampingScale() * Profile.ConeLimit.Damping;

					JointSettings.LinearRestitution = Profile.LinearLimit.Restitution;
					JointSettings.TwistRestitution = Profile.TwistLimit.Restitution;
					JointSettings.SwingRestitution = Profile.ConeLimit.Restitution;

					JointSettings.LinearContactDistance = Profile.LinearLimit.ContactDistance;

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

Scope (from outer to inner):

file
function     void FPhysInterface_Chaos::UpdateConeLimitParams_AssumesLocked

Source code excerpt:

			Constraint->SetSoftSwingLimitsEnabled(InParams.bSoftConstraint);
			Constraint->SetSoftSwingStiffness(Chaos::ConstraintSettings::SoftAngularStiffnessScale() * InParams.Stiffness);
			Constraint->SetSoftSwingDamping(Chaos::ConstraintSettings::SoftAngularDampingScale() * InParams.Damping);
			Constraint->SetSwingContactDistance(InParams.ContactDistance);
			Constraint->SetSwingRestitution(InParams.Restitution);
			//Constraint->SetAngularSoftForceMode( InParams.NOT_QUITE_SURE ); // @todo(chaos) 
		}
	}
}

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

Scope (from outer to inner):

file
function     void FPhysInterface_Chaos::UpdateTwistLimitParams_AssumesLocked

Source code excerpt:

			Constraint->SetSoftTwistLimitsEnabled(InParams.bSoftConstraint);
			Constraint->SetSoftTwistStiffness(Chaos::ConstraintSettings::SoftAngularStiffnessScale() * InParams.Stiffness);
			Constraint->SetSoftTwistDamping(Chaos::ConstraintSettings::SoftAngularDampingScale() * InParams.Damping);
			Constraint->SetTwistContactDistance(InParams.ContactDistance);
			Constraint->SetTwistRestitution(InParams.Restitution);
			//Constraint->SetAngularSoftForceMode( InParams.NOT_QUITE_SURE ); // @todo(chaos) 

		}
	}

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

Scope (from outer to inner):

file
namespace    ImmediatePhysics_Chaos
function     void TransferJointSettings

Source code excerpt:

		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;
		ConstraintSettings.AngularSoftForceMode = (Chaos::ConstraintSettings::SoftAngularForceMode() == 0) ? EJointForceMode::Acceleration : EJointForceMode::Force;

		if (!ConstraintSettings.bSoftLinearLimitsEnabled)
		{
			ConstraintSettings.LinearRestitution = Profile.LinearLimit.Restitution;

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    JointConstraintDefaults

Source code excerpt:

		int SoftAngularForceMode = (int)EJointForceMode::Acceleration;
		float SoftAngularStiffnessScale = 100000;
		float SoftAngularDampingScale = 1000; 

		float LinearBreakScale = 1.0f;
		float AngularBreakScale = 1.0f;

		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."));

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    JointConstraintDefaults

Source code excerpt:

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

	FReal ConstraintSettings::JointStiffness() { return JointConstraintDefaults::JointStiffness;}
	FReal ConstraintSettings::LinearDriveStiffnessScale() { return JointConstraintDefaults::LinearDriveStiffnessScale;}

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

Scope (from outer to inner):

file
namespace    Chaos
function     FReal ConstraintSettings::SoftAngularDampingScale

Source code excerpt:

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

Scope (from outer to inner):

file
namespace    Chaos
class        class ConstraintSettings

Source code excerpt:

		static PHYSICSCORE_API int SoftAngularForceMode();
		static PHYSICSCORE_API FReal SoftAngularStiffnessScale();
		static PHYSICSCORE_API FReal SoftAngularDampingScale();

		static PHYSICSCORE_API FReal LinearBreakScale();
		static PHYSICSCORE_API FReal AngularBreakScale();
	};
}