p.Chaos.Solver.bChaosForceMACD

p.Chaos.Solver.bChaosForceMACD

#Overview

name: p.Chaos.Solver.bChaosForceMACD

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

It is referenced in 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.Solver.bChaosForceMACD is to force all collisions to use Motion-Aware Collision Detection (MACD) for testing purposes in the Chaos physics system of Unreal Engine 5.

This setting variable is primarily used by the Chaos physics system, which is an experimental physics solver in Unreal Engine 5. It’s specifically related to the collision detection subsystem within Chaos.

The value of this variable is set through the Unreal Engine console variable system. It’s defined as a boolean value, defaulting to false, and can be changed at runtime using the console command system.

This variable interacts closely with another variable called bChaosUseMACD. For p.Chaos.Solver.bChaosForceMACD to have an effect, bChaosUseMACD must also be enabled.

Developers must be aware that this variable is intended for testing purposes. Forcing all collisions to use MACD might have performance implications and may not be suitable for all scenarios in a production environment.

Best practices when using this variable include:

  1. Only enable it when specifically testing MACD behavior.
  2. Ensure bChaosUseMACD is also enabled for it to take effect.
  3. Monitor performance when enabled, as it may impact frame rates.
  4. Use it in conjunction with other Chaos physics settings for comprehensive testing.

Regarding the associated variable bChaosForceMACD:

The purpose of bChaosForceMACD is the same as p.Chaos.Solver.bChaosForceMACD - to force all collisions to use MACD for testing.

This variable is used in various parts of the Chaos physics system, including particle pair collision detection and the rigid body evolution system.

The value of bChaosForceMACD is set by the console variable p.Chaos.Solver.bChaosForceMACD.

It interacts with other variables such as bChaosUseMACD and collision settings for individual particles.

Developers should be aware that this variable can override individual particle MACD settings when enabled.

Best practices for using bChaosForceMACD include:

  1. Use it in conjunction with p.Chaos.Solver.bChaosForceMACD for consistency.
  2. Be cautious when using it in production builds, as it’s primarily intended for testing and debugging.
  3. Consider the performance implications of forcing MACD for all collisions.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:382

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		// Use to force all collisions to use MACD for testing (must also have bChaosUseMACD enabled)
		bool bChaosForceMACD = false;
		FAutoConsoleVariableRef CVarChaos_Collision_ForceMACD(TEXT("p.Chaos.Solver.bChaosForceMACD"), bChaosForceMACD, TEXT("Force all collisions to use MACD for testing"), OnCollisionConfigCVarChanged);

		// Joint cvars
		float ChaosSolverJointMinSolverStiffness = 1.0f;
		float ChaosSolverJointMaxSolverStiffness = 1.0f;
		int32 ChaosSolverJointNumIterationsAtMaxSolverStiffness = 1;
		bool bChaosSolverJointSolvePositionLast = true;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/ParticlePairMidPhase.cpp:64

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		extern int32 ChaosOneWayInteractionPairCollisionMode;

		extern bool bChaosForceMACD;
	}

	using namespace CVars;


	////////////////////////////////////////////////////////////////////////////////////////

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/ParticlePairMidPhase.cpp:882

Scope (from outer to inner):

file
namespace    Chaos
function     void FParticlePairMidPhase::Init

Source code excerpt:

		// Enable Motion-Aware Collision Detection if either particle requests it
		// (NOTE: MACD also affects how the particle world-space bounds is expanded in the broadphase)
		const bool bIsMACD = Context.GetSettings().bAllowMACD && (CVars::bChaosForceMACD || P0->MACDEnabled() || P1->MACDEnabled());
		Flags.bIsMACD = bIsMACD;

		// Initially we allow for convex optimization where available
		Flags.bIsConvexOptimizationActive = true;

		BuildDetectorsImpl();

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		// Debug/testing MACD
		extern bool bChaosUseMACD;
		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"));

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

Scope (from outer to inner):

file
namespace    Chaos
function     void FPBDRigidsEvolutionGBF::Integrate

Source code excerpt:

	const FReal HackMaxLinearSpeedSq = CVars::HackMaxVelocity * CVars::HackMaxVelocity;
	const bool bAllowMACD = CVars::bChaosUseMACD;
	const bool bForceMACD = CVars::bChaosForceMACD;

	ParticlesView.ParallelFor([&](auto& GeomParticle, int32 Index)
		{
			//question: can we enforce this at the API layer? Right now islands contain non dynamic which makes this hard
			auto PBDParticle = GeomParticle.CastToRigidParticle();
			if (PBDParticle && PBDParticle->ObjectState() == EObjectStateType::Dynamic)

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:381

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:


		// Use to force all collisions to use MACD for testing (must also have bChaosUseMACD enabled)
		bool bChaosForceMACD = false;
		FAutoConsoleVariableRef CVarChaos_Collision_ForceMACD(TEXT("p.Chaos.Solver.bChaosForceMACD"), bChaosForceMACD, TEXT("Force all collisions to use MACD for testing"), OnCollisionConfigCVarChanged);

		// Joint cvars
		float ChaosSolverJointMinSolverStiffness = 1.0f;
		float ChaosSolverJointMaxSolverStiffness = 1.0f;
		int32 ChaosSolverJointNumIterationsAtMaxSolverStiffness = 1;
		bool bChaosSolverJointSolvePositionLast = true;