p.Chaos.Collision.CCD.UseTightBoundingBox

p.Chaos.Collision.CCD.UseTightBoundingBox

#Overview

name: p.Chaos.Collision.CCD.UseTightBoundingBox

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

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.Chaos.Collision.CCD.UseTightBoundingBox is to control the bounding box calculation for Continuous Collision Detection (CCD) in the Chaos physics system of Unreal Engine 5. This setting variable is specifically used in the collision detection subsystem of the Chaos physics engine.

The Chaos physics system, which is part of Unreal Engine’s experimental features, relies on this setting variable. It is used within the PBDRigidsEvolutionGBF (Position Based Dynamics Rigid Evolution) module, which handles the evolution of rigid bodies in the physics simulation.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be changed at runtime through console commands. It is initialized to true by default.

This variable interacts closely with another variable named ChaosCollisionCCDConstraintMaxProcessCount. When UseTightBoundingBox is false and ChaosCollisionCCDConstraintMaxProcessCount is greater than 1, the bounding box expansion is increased to account for potential secondary CCD collisions.

Developers must be aware that using a tight bounding box (when this variable is set to true) may cause the system to miss secondary CCD collisions if the first collision(s) result in a change of direction, especially when there is more than one CCD iteration.

Best practices when using this variable include:

  1. Consider setting it to false if you’re using multiple CCD iterations and need to capture secondary collisions accurately.
  2. Monitor performance impacts, as using a larger bounding box (false setting) may increase computational cost.
  3. Test thoroughly with both true and false settings to ensure desired collision behavior in your specific use case.

Regarding the associated variable bChaosCollisionCCDUseTightBoundingBox:

This is the actual boolean variable that stores the state controlled by the console variable. It is used directly in the code to determine the behavior of the CCD system. When this variable is false and there are multiple CCD iterations, the code expands the bounding box by the maximum component of the velocity-time product, in addition to the standard bounds thickness.

The same considerations and best practices apply to this variable as they do to the console variable. Developers should be aware that changing one will affect the other, as they are directly linked through the FAutoConsoleVariableRef.

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		// NOTE: If we have mrope than 1 CCD iteration (ChaosCollisionCCDConstraintMaxProcessCount), the tight bounding box will cause us to miss secondary CCD collisions if the first one(s) result in a change in direction
		bool bChaosCollisionCCDUseTightBoundingBox = true;
		FAutoConsoleVariableRef  CVarChaosCollisionCCDUseTightBoundingBox(TEXT("p.Chaos.Collision.CCD.UseTightBoundingBox"), bChaosCollisionCCDUseTightBoundingBox , TEXT(""));

		// Collision Solver Type (see ECollisionSolverType)
		int32 ChaosSolverCollisionSolverType = -1;
		FAutoConsoleVariableRef CVarChaosSolverCollisionSolverType(TEXT("p.Chaos.Solver.Collision.SolverType"), ChaosSolverCollisionSolverType, TEXT("-1: Use default (Gauss Seidel); 0: Gauss Seidel; 1: Gauss Seidel SOA 2: Partial Jacobi"));

		int32 ChaosSolverCollisionPriority = 0;

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:


		// NOTE: If we have mrope than 1 CCD iteration (ChaosCollisionCCDConstraintMaxProcessCount), the tight bounding box will cause us to miss secondary CCD collisions if the first one(s) result in a change in direction
		bool bChaosCollisionCCDUseTightBoundingBox = true;
		FAutoConsoleVariableRef  CVarChaosCollisionCCDUseTightBoundingBox(TEXT("p.Chaos.Collision.CCD.UseTightBoundingBox"), bChaosCollisionCCDUseTightBoundingBox , TEXT(""));

		// Collision Solver Type (see ECollisionSolverType)
		int32 ChaosSolverCollisionSolverType = -1;
		FAutoConsoleVariableRef CVarChaosSolverCollisionSolverType(TEXT("p.Chaos.Solver.Collision.SolverType"), ChaosSolverCollisionSolverType, TEXT("-1: Use default (Gauss Seidel); 0: Gauss Seidel; 1: Gauss Seidel SOA 2: Partial Jacobi"));

		int32 ChaosSolverCollisionPriority = 0;

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

Scope (from outer to inner):

file
function     void FPBDRigidsEvolutionGBF::Integrate
lambda-function

Source code excerpt:

						const FVec3 VDt = V * Dt;
						FReal CCDBoundsExpansion = BoundsThickness;
						if (!CVars::bChaosCollisionCCDUseTightBoundingBox && (CVars::ChaosCollisionCCDConstraintMaxProcessCount > 1))
						{
							CCDBoundsExpansion += VDt.GetAbsMax();
						}
						Particle.UpdateWorldSpaceStateSwept(FRigidTransform3(Particle.GetP(), Particle.GetQ()), FVec3(CCDBoundsExpansion), -VDt);
					}
					else

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

		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;
	}

	using FPBDRigidsEvolutionCallback = TFunction<void(FReal Dt)>;