p.HackMaxAngularVelocity

p.HackMaxAngularVelocity

#Overview

name: p.HackMaxAngularVelocity

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.HackMaxAngularVelocity is to set a maximum cap on angular velocity in the Chaos physics system of Unreal Engine 5. It is measured in radians per second and is primarily used as a temporary solution for limiting angular velocity in physics simulations.

This setting variable is primarily used in the Chaos physics module, which is part of Unreal Engine’s experimental physics system. It is referenced in the PBDRigidsEvolutionGBF (Position Based Dynamics Rigid Evolution) component of the Chaos system.

The value of this variable is set through the console variable system, allowing it to be adjusted at runtime. It is initialized with a default value of 1000.0 radians per second.

The associated variable HackMaxAngularVelocity directly interacts with p.HackMaxAngularVelocity, sharing the same value. This variable is used in the actual physics calculations within the Integrate function of FPBDRigidsEvolutionGBF.

Developers must be aware that this is explicitly described as a temporary solution and should not be relied upon as a permanent feature. The comment in the code suggests that setting the value to -1.0f will disable this cap.

Best practices when using this variable include:

  1. Only use it for debugging or as a temporary fix for physics issues.
  2. Be cautious about relying on it for gameplay mechanics, as it may be removed or changed in future engine versions.
  3. Consider using proper physics constraints or other methods for long-term solutions to angular velocity issues.

Regarding the associated variable HackMaxAngularVelocity:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidsEvolutionGBF.cpp:44

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:


		FRealSingle HackMaxAngularVelocity = 1000.f;
		FAutoConsoleVariableRef CVarHackMaxAngularVelocity(TEXT("p.HackMaxAngularVelocity"), HackMaxAngularVelocity, TEXT("Max cap on angular velocity: rad/s. This is only a temp solution and should not be relied on as a feature. -1.f to disable"));

		FRealSingle HackMaxVelocity = -1.f;
		FAutoConsoleVariableRef CVarHackMaxVelocity(TEXT("p.HackMaxVelocity2"), HackMaxVelocity, TEXT("Max cap on velocity: cm/s. This is only a temp solution and should not be relied on as a feature. -1.f to disable"));


		int DisableThreshold = 5;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidsEvolutionGBF.cpp:43

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		extern bool bChaosForceMACD;

		FRealSingle HackMaxAngularVelocity = 1000.f;
		FAutoConsoleVariableRef CVarHackMaxAngularVelocity(TEXT("p.HackMaxAngularVelocity"), HackMaxAngularVelocity, TEXT("Max cap on angular velocity: rad/s. This is only a temp solution and should not be relied on as a feature. -1.f to disable"));

		FRealSingle HackMaxVelocity = -1.f;
		FAutoConsoleVariableRef CVarHackMaxVelocity(TEXT("p.HackMaxVelocity2"), HackMaxVelocity, TEXT("Max cap on velocity: cm/s. This is only a temp solution and should not be relied on as a feature. -1.f to disable"));


		int DisableThreshold = 5;

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidsEvolutionGBF.cpp:751

Scope (from outer to inner):

file
namespace    Chaos
function     void FPBDRigidsEvolutionGBF::Integrate

Source code excerpt:

	const FReal VelocityBoundsMultiplierMACD = GetCollisionConstraints().GetDetectorSettings().BoundsVelocityInflationMACD;
	const FReal MaxVelocityBoundsExpansionMACD = GetCollisionConstraints().GetDetectorSettings().MaxVelocityBoundsExpansionMACD;
	const FReal HackMaxAngularSpeedSq = CVars::HackMaxAngularVelocity * CVars::HackMaxAngularVelocity;
	const FReal HackMaxLinearSpeedSq = CVars::HackMaxVelocity * CVars::HackMaxVelocity;
	const bool bAllowMACD = CVars::bChaosUseMACD;
	const bool bForceMACD = CVars::bChaosForceMACD;

	ParticlesView.ParallelFor([&](auto& GeomParticle, int32 Index)
		{

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidsEvolutionGBF.cpp:808

Scope (from outer to inner):

file
namespace    Chaos
function     void FPBDRigidsEvolutionGBF::Integrate
lambda-function

Source code excerpt:

				}

				if (CVars::HackMaxAngularVelocity >= 0.f)
				{
					AngularSpeedSq = W.SizeSquared();
					if (AngularSpeedSq > HackMaxAngularSpeedSq)
					{
						W = W * (CVars::HackMaxAngularVelocity / FMath::Sqrt(AngularSpeedSq));
					}
				}

				if (CVars::HackMaxVelocity >= 0.f)
				{
					LinearSpeedSq = V.SizeSquared();

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/PBDRigidsEvolutionGBF.h:29

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

	namespace CVars
	{
		CHAOS_API extern FRealSingle HackMaxAngularVelocity;
		CHAOS_API extern FRealSingle HackMaxVelocity;
		CHAOS_API extern FRealSingle SmoothedPositionLerpRate;
		CHAOS_API extern bool bChaosCollisionCCDUseTightBoundingBox;
		CHAOS_API extern int32 ChaosCollisionCCDConstraintMaxProcessCount;
		CHAOS_API extern int32 ChaosSolverDrawCCDThresholds;
	}