p.Chaos.PBDCollisionSolver.EnableSoftCollisions

p.Chaos.PBDCollisionSolver.EnableSoftCollisions

#Overview

name: p.Chaos.PBDCollisionSolver.EnableSoftCollisions

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.PBDCollisionSolver.EnableSoftCollisions is to control whether the experimental soft collisions feature is enabled in the Chaos physics system of Unreal Engine 5.

This setting variable is primarily used in the Chaos physics subsystem, which is part of the Experimental module in Unreal Engine 5. It specifically affects the Position-Based Dynamics (PBD) collision solver within Chaos.

The value of this variable is set using the Unreal Engine console variable system. It’s initialized to true by default, as seen in the source code:

bool bChaos_Collision_EnableSoftCollisions = true;
FAutoConsoleVariableRef CVarChaosCollisionEnableSoftCollisions(TEXT("p.Chaos.PBDCollisionSolver.EnableSoftCollisions"), bChaos_Collision_EnableSoftCollisions, TEXT(""));

This variable interacts directly with its associated boolean variable bChaos_Collision_EnableSoftCollisions. They share the same value, and the console variable acts as an interface to modify this value at runtime.

Developers should be aware that this feature is experimental, as indicated by its location in the Experimental namespace and the comment in the code. Using this variable might affect the behavior of collision detection and resolution in the physics simulation, particularly for soft body physics or deformable objects.

Best practices when using this variable include:

  1. Testing thoroughly when enabling or disabling this feature, as it may significantly impact physics behavior.
  2. Being cautious about enabling it in production builds until it’s no longer considered experimental.
  3. Monitoring performance impacts, as soft collisions may be more computationally expensive.

Regarding the associated variable bChaos_Collision_EnableSoftCollisions:

The purpose of this boolean variable is to store the actual state of whether soft collisions are enabled or not. It’s used directly in the collision solving logic:

if (Constraint->IsSoftContact() && CVars::bChaos_Collision_EnableSoftCollisions)

This check determines whether to apply soft contact calculations during collision solving. The variable is part of the CVars namespace within Chaos, indicating it’s a console variable accessible for runtime configuration.

Developers should be aware that changes to p.Chaos.PBDCollisionSolver.EnableSoftCollisions will directly affect this boolean, and thus the behavior of the collision solver. When working with physics simulations, particularly those involving soft bodies or deformable objects, developers may need to toggle this variable to achieve desired collision behaviors or to troubleshoot physics-related issues.

#References in C++ code

#Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		// Whether to enable the experimental soft collisions
		bool bChaos_Collision_EnableSoftCollisions = true;
		FAutoConsoleVariableRef CVarChaosCollisionEnableSoftCollisions(TEXT("p.Chaos.PBDCollisionSolver.EnableSoftCollisions"), bChaos_Collision_EnableSoftCollisions, TEXT(""));
	}


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

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:


		// Whether to enable the experimental soft collisions
		bool bChaos_Collision_EnableSoftCollisions = true;
		FAutoConsoleVariableRef CVarChaosCollisionEnableSoftCollisions(TEXT("p.Chaos.PBDCollisionSolver.EnableSoftCollisions"), bChaos_Collision_EnableSoftCollisions, TEXT(""));
	}


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

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

Scope (from outer to inner):

file
namespace    Chaos
function     void UpdateCollisionSolverFromConstraint

Source code excerpt:

		// Convert to a soft collision if the constraint has a nonzero soft separation
		// NOTE: must come after UpdateCollisionSolverManifoldFromConstraint because we scale the spring forces by the number of manifold points.
		if (Constraint->IsSoftContact() && CVars::bChaos_Collision_EnableSoftCollisions)
		{
			// NOTE: convert stiffness and damping into XPBD terms
			if (Solver.NumManifoldPoints() > 0)
			{
				const FSolverReal SoftScale = FSolverReal(1) / FSolverReal(Solver.NumManifoldPoints());
				Solver.SetSoftContact(Constraint->GetSoftSeparation());