p.Chaos.RemoveParticleFromMovingKinematicsOnDisable

p.Chaos.RemoveParticleFromMovingKinematicsOnDisable

#Overview

name: p.Chaos.RemoveParticleFromMovingKinematicsOnDisable

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.Chaos.RemoveParticleFromMovingKinematicsOnDisable is to control a bug fix in the Chaos physics engine of Unreal Engine 5. Specifically, it determines whether to remove a particle from the moving kinematics list when it is disabled.

This setting variable is primarily used in the Chaos physics subsystem, which is part of Unreal Engine’s experimental features. It’s referenced in the PBDRigidsSolver and PBDRigidsSOAs components of the Chaos namespace.

The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be modified at runtime through console commands. It’s initialized to true by default.

The associated variable bRemoveParticleFromMovingKinematicsOnDisable interacts directly with this console variable. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable controls a bug fix, and changing its value may affect the behavior of physics simulations, particularly when disabling particles or changing their state.

Best practices when using this variable include:

  1. Keeping it enabled (true) unless specific issues arise from the bug fix.
  2. Testing thoroughly if you decide to disable it, as it may reintroduce the bug it was designed to fix.
  3. Being cautious when modifying it at runtime, as it could impact ongoing physics simulations.

Regarding the associated variable bRemoveParticleFromMovingKinematicsOnDisable:

The purpose of bRemoveParticleFromMovingKinematicsOnDisable is to serve as an internal flag within the Chaos physics system that determines whether to remove a particle from the moving kinematics list when it is disabled.

This variable is used in the Chaos physics subsystem, specifically in the PBDRigidsSOAs class, which handles the Structure of Arrays (SOA) for Position Based Dynamics (PBD) rigid bodies.

The value of this variable is set by the console variable p.Chaos.RemoveParticleFromMovingKinematicsOnDisable.

It interacts directly with the console variable and is used in conditional statements to determine whether to remove particles from the MovingKinematicsMapArray when disabling particles or changing their state.

Developers should be aware that this variable affects the behavior of particle disabling and state changes in the physics simulation. Modifying it could have implications for performance and accuracy of physics calculations.

Best practices for using this variable include:

  1. Avoiding direct modification of this variable, instead use the console variable to change its value if necessary.
  2. Considering the impact on physics simulations when changing its value, especially in production environments.
  3. Using it in conjunction with other Chaos physics settings for optimal performance and behavior.

#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:406

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		// Enable a couple bug fixes with temporary roll-back just in case
		bool bRemoveParticleFromMovingKinematicsOnDisable = true;
		FAutoConsoleVariableRef CVarChaosRemoveParticleFromMovingKinematicsOnDisable(TEXT("p.Chaos.RemoveParticleFromMovingKinematicsOnDisable"), bRemoveParticleFromMovingKinematicsOnDisable, TEXT(""));
	}
}

namespace PhysicsReplicationCVars
{
	namespace ResimulationCVars

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:


		// Enable a couple bug fixes with temporary roll-back just in case
		bool bRemoveParticleFromMovingKinematicsOnDisable = true;
		FAutoConsoleVariableRef CVarChaosRemoveParticleFromMovingKinematicsOnDisable(TEXT("p.Chaos.RemoveParticleFromMovingKinematicsOnDisable"), bRemoveParticleFromMovingKinematicsOnDisable, TEXT(""));
	}
}

namespace PhysicsReplicationCVars
{
	namespace ResimulationCVars

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/PBDRigidsSOAs.h:9

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

namespace CVars
{
	extern CHAOS_API bool bRemoveParticleFromMovingKinematicsOnDisable;
	extern CHAOS_API bool bChaosSolverCheckParticleViews;
}

// A helper function to get the debug name for a particle or "UNKNOWN" when debug names are unavailable
template<typename TParticleType>
const FString& GetParticleDebugName(const TParticleType& Particle)

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/PBDRigidsSOAs.h:520

Scope (from outer to inner):

file
namespace    Chaos
class        class FPBDRigidsSOAs
function     void DisableParticle

Source code excerpt:

			{
				RemoveFromActiveArray(PBDRigid, /*bStillDirty=*/false);
				if (CVars::bRemoveParticleFromMovingKinematicsOnDisable)
				{
					RemoveFromList(PBDRigid, MovingKinematicsMapArray);
				}
			}
		}
		else if (Particle->CastToKinematicParticle())

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/PBDRigidsSOAs.h:699

Scope (from outer to inner):

file
namespace    Chaos
class        class FPBDRigidsSOAs
function     void SetDynamicParticleSOA

Source code excerpt:

			Particle->MoveToSOA(*DynamicDisabledParticles);
			RemoveFromActiveArray(Particle->CastToRigidParticle(), /*bStillDirty=*/ false);
			if (CVars::bRemoveParticleFromMovingKinematicsOnDisable)
			{
				RemoveFromList(Particle, MovingKinematicsMapArray);
			}
		}
		else
		{