p.Chaos.JointConstraint.LinearBreakScale

p.Chaos.JointConstraint.LinearBreakScale

#Overview

name: p.Chaos.JointConstraint.LinearBreakScale

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

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.JointConstraint.LinearBreakScale is to provide a conversion factor for the Linear Break Threshold in the Chaos physics engine’s joint constraint system. This setting variable is primarily used in the physics simulation subsystem of Unreal Engine 5, specifically within the Chaos physics engine.

The Chaos physics engine, which is part of Unreal Engine’s PhysicsCore module, relies on this setting variable to scale the linear break threshold for joint constraints. This scaling factor is applied when calculating the force required to break a joint linearly.

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 using the console command system.

The associated variable LinearBreakScale interacts directly with p.Chaos.JointConstraint.LinearBreakScale. They share the same value and are used interchangeably in the code.

Developers must be aware that modifying this variable will affect the breaking behavior of all joint constraints in the simulation. A higher value will make joints more resistant to breaking, while a lower value will make them break more easily.

Best practices when using this variable include:

  1. Use it to fine-tune the overall joint breaking behavior in your simulation.
  2. Be cautious when changing its value, as it affects all joints globally.
  3. Consider using it in conjunction with per-joint settings for more precise control.
  4. Document any changes made to this variable, as it can significantly impact physics behavior.

Regarding the associated variable LinearBreakScale:

The purpose of LinearBreakScale is to store and provide access to the linear break scale value within the Chaos physics engine. It’s used in various parts of the physics simulation to apply the scaling factor to joint break thresholds.

This variable is used in multiple subsystems within the Chaos physics engine, including the PhysicsControl plugin and the ImmediatePhysics system.

The value of LinearBreakScale is set by the p.Chaos.JointConstraint.LinearBreakScale console variable and can be accessed through the Chaos::ConstraintSettings::LinearBreakScale() function.

LinearBreakScale interacts directly with joint constraint calculations, particularly when determining if a joint should break due to linear forces.

Developers should be aware that this variable is used in critical physics calculations and should be modified with caution. Changes to this value will affect the behavior of joint constraints throughout the entire physics simulation.

Best practices for using LinearBreakScale include:

  1. Access it through the provided ConstraintSettings::LinearBreakScale() function rather than directly.
  2. Consider the impact on existing physics setups when modifying this value.
  3. Use it in conjunction with other joint settings for comprehensive physics behavior control.
  4. Test thoroughly after making any changes to ensure desired physics behavior is maintained across all use cases.

#References in C++ code

#Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    JointConstraintDefaults

Source code excerpt:

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

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
function     void FAnimNode_RigidBodyWithControl::ApplyCurrentConstraintProfile

Source code excerpt:


					JointSettings.LinearBreakForce = Profile.bLinearBreakable ? 
						Chaos::ConstraintSettings::LinearBreakScale() * Profile.LinearBreakThreshold : FLT_MAX;
					JointSettings.LinearPlasticityLimit = Profile.bLinearPlasticity ? 
						FMath::Clamp((float)Profile.LinearPlasticityThreshold, 0.0f, 1.0f) : FLT_MAX;
					JointSettings.LinearPlasticityType = ConvertPlasticityType(Profile.LinearPlasticityType);
					// JointSettings.LinearPlasticityInitialDistanceSquared = ; // What do we do with this?

					JointSettings.AngularBreakTorque = Profile.bAngularBreakable ? 

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

Scope (from outer to inner):

file
namespace    ImmediatePhysics_Chaos
function     void TransferJointSettings

Source code excerpt:

		ConstraintSettings.AngularDriveForceMode = EJointForceMode::Acceleration;

		ConstraintSettings.LinearBreakForce = (Profile.bLinearBreakable) ? Chaos::ConstraintSettings::LinearBreakScale() * Profile.LinearBreakThreshold : FLT_MAX;
		ConstraintSettings.LinearPlasticityLimit = (Profile.bLinearPlasticity) ? FMath::Clamp((float)Profile.LinearPlasticityThreshold, 0.f, 1.f) : FLT_MAX;
		ConstraintSettings.AngularBreakTorque = (Profile.bAngularBreakable) ? Chaos::ConstraintSettings::AngularBreakScale() * Profile.AngularBreakThreshold : FLT_MAX;
		ConstraintSettings.AngularPlasticityLimit = (Profile.bAngularPlasticity) ? Profile.AngularPlasticityThreshold : FLT_MAX;

		ConstraintSettings.ContactTransferScale = 0.0f;

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    JointConstraintDefaults

Source code excerpt:

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

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    JointConstraintDefaults

Source code excerpt:

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

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

Scope (from outer to inner):

file
namespace    Chaos
function     FReal ConstraintSettings::LinearBreakScale

Source code excerpt:

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

Scope (from outer to inner):

file
namespace    Chaos
class        class ConstraintSettings

Source code excerpt:

		static PHYSICSCORE_API FReal SoftAngularDampingScale();

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