p.Chaos.Joint.DegenerateRotationLimit
p.Chaos.Joint.DegenerateRotationLimit
#Overview
name: p.Chaos.Joint.DegenerateRotationLimit
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Cosine of the swing angle that is considered degerenerate (default Cos(176deg))
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.Joint.DegenerateRotationLimit is to define a threshold for detecting degenerate rotations in joint constraints within the Chaos physics system of Unreal Engine 5. It specifically sets the cosine of the swing angle that is considered degenerate, with a default value equivalent to cos(176 degrees).
This setting variable is primarily used by the Chaos physics subsystem, particularly within the joint constraint solver. It’s referenced in the Experimental/Chaos module, which is part of Unreal Engine’s physics system.
The value of this variable is set in the JointConstraintsCVars.cpp file, with a default value of -0.998f. It can be modified at runtime through the console variable system.
The associated variable Chaos_Joint_DegenerateRotationLimit directly interacts with p.Chaos.Joint.DegenerateRotationLimit. They share the same value and are used interchangeably in the code.
Developers should be aware that this variable is crucial for handling edge cases in joint rotations. It helps prevent numerical instability when joint rotations approach 180 degrees (or π radians) of swing.
Best practices when using this variable include:
- Only modify it if you fully understand the implications on joint behavior and physics simulation stability.
- If adjusting, test thoroughly to ensure it doesn’t introduce unexpected behavior in extreme joint rotations.
- Monitor performance and stability when changing this value, as it can affect the frequency of degenerate rotation handling.
Regarding the associated variable Chaos_Joint_DegenerateRotationLimit:
- It serves the same purpose as p.Chaos.Joint.DegenerateRotationLimit.
- It’s used directly in the C++ code for comparisons in various joint-related functions.
- It’s defined in the same file (JointConstraintsCVars.cpp) and is exposed through the console variable system.
- The variable is used in multiple locations within the Chaos physics system, particularly in functions dealing with rotation constraints and angular velocity constraints.
- Developers should treat it with the same care as p.Chaos.Joint.DegenerateRotationLimit, as they are effectively the same variable.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Joint/JointConstraintsCVars.cpp:8
Scope: file
Source code excerpt:
float Chaos_Joint_DegenerateRotationLimit = -0.998f; // Cos(176deg)
FAutoConsoleVariableRef CVarChaosJointDegenerateRotationLimit(TEXT("p.Chaos.Joint.DegenerateRotationLimit"), Chaos_Joint_DegenerateRotationLimit, TEXT("Cosine of the swing angle that is considered degerenerate (default Cos(176deg))"));
float Chaos_Joint_VelProjectionAlpha = 0.1f;
FAutoConsoleVariableRef CVarChaosJointVelProjectionScale(TEXT("p.Chaos.Joint.VelProjectionAlpha"), Chaos_Joint_VelProjectionAlpha, TEXT("How much of the velocity correction to apply during projection. Equivalent to (1-damping) for projection velocity delta"));
bool bChaos_Joint_DisableSoftLimits = false;
FAutoConsoleVariableRef CVarChaosJointDisableSoftLimits(TEXT("p.Chaos.Joint.DisableSoftLimits"), bChaos_Joint_DisableSoftLimits, TEXT("Disable soft limits (for debugging only)"));
#Associated Variable and Callsites
This variable is associated with another variable named Chaos_Joint_DegenerateRotationLimit
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Joint/JointConstraintsCVars.cpp:7
Scope: file
Source code excerpt:
#endif
float Chaos_Joint_DegenerateRotationLimit = -0.998f; // Cos(176deg)
FAutoConsoleVariableRef CVarChaosJointDegenerateRotationLimit(TEXT("p.Chaos.Joint.DegenerateRotationLimit"), Chaos_Joint_DegenerateRotationLimit, TEXT("Cosine of the swing angle that is considered degerenerate (default Cos(176deg))"));
float Chaos_Joint_VelProjectionAlpha = 0.1f;
FAutoConsoleVariableRef CVarChaosJointVelProjectionScale(TEXT("p.Chaos.Joint.VelProjectionAlpha"), Chaos_Joint_VelProjectionAlpha, TEXT("How much of the velocity correction to apply during projection. Equivalent to (1-damping) for projection velocity delta"));
bool bChaos_Joint_DisableSoftLimits = false;
FAutoConsoleVariableRef CVarChaosJointDisableSoftLimits(TEXT("p.Chaos.Joint.DisableSoftLimits"), bChaos_Joint_DisableSoftLimits, TEXT("Disable soft limits (for debugging only)"));
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Joint/JointConstraintsCVars.h:16
Scope: file
Source code excerpt:
extern bool bChaos_Joint_EarlyOut_Enabled;
extern float Chaos_Joint_DegenerateRotationLimit;
extern float Chaos_Joint_VelProjectionAlpha;
extern bool bChaos_Joint_DisableSoftLimits;
extern bool bChaos_Joint_Plasticity_ClampToLimits;
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Joint/PBDJointCachedSolverGaussSeidel.cpp:869
Scope (from outer to inner):
file
namespace Chaos
function void FPBDJointCachedSolver::InitRotationConstraints
Source code excerpt:
const FVec3 Twist0 = ConnectorRs[0] * FJointConstants::TwistAxis();
const FVec3 Twist1 = ConnectorRs[1] * FJointConstants::TwistAxis();
const bool bDegenerate = (FVec3::DotProduct(Twist0, Twist1) < Chaos_Joint_DegenerateRotationLimit);
// Apply twist constraint
// NOTE: Cannot calculate twist angle at 180degree swing
if (SolverSettings.bEnableTwistLimits)
{
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Joint/PBDJointSolverGaussSeidel.cpp:446
Scope (from outer to inner):
file
namespace Chaos
function void FPBDJointSolver::ApplyRotationConstraints
Source code excerpt:
const FVec3 Twist1 = ConnectorRs[1] * FJointConstants::TwistAxis();
const FReal Twist01Dot = FVec3::DotProduct(Twist0, Twist1);
const bool bDegenerate = (Twist01Dot < Chaos_Joint_DegenerateRotationLimit);
if (bDegenerate)
{
UE_LOG(LogChaosJoint, VeryVerbose, TEXT(" Degenerate rotation at Swing %f deg"), FMath::RadiansToDegrees(FMath::Acos(Twist01Dot)));
}
// Apply twist constraint
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Joint/PBDJointSolverGaussSeidel.cpp:836
Scope (from outer to inner):
file
namespace Chaos
function void FPBDJointSolver::ApplyAngularVelocityConstraints
Source code excerpt:
const FVec3 Twist1 = ConnectorRs[1] * FJointConstants::TwistAxis();
const FReal Twist01Dot = FVec3::DotProduct(Twist0, Twist1);
const bool bDegenerate = (Twist01Dot < Chaos_Joint_DegenerateRotationLimit);
if (bDegenerate)
{
UE_LOG(LogChaosJoint, VeryVerbose, TEXT(" Degenerate rotation at Swing %f deg"), FMath::RadiansToDegrees(FMath::Acos(Twist01Dot)));
}
// Apply twist constraint
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Joint/PBDJointSolverGaussSeidel.cpp:2796
Scope (from outer to inner):
file
namespace Chaos
function void FPBDJointSolver::CalculateConstraintAxisAngularVelocities
Source code excerpt:
const FVec3 Twist1 = ConnectorRs[1] * FJointConstants::TwistAxis();
const FReal Twist01Dot = FVec3::DotProduct(Twist0, Twist1);
const bool bDegenerate = (Twist01Dot < Chaos_Joint_DegenerateRotationLimit);
if (bDegenerate)
{
UE_LOG(LogChaosJoint, VeryVerbose, TEXT(" Degenerate rotation at Swing %f deg"), FMath::RadiansToDegrees(FMath::Acos(Twist01Dot)));
}
// Apply twist constraint