p.Chaos.Collision.EnableBoundsChecks
p.Chaos.Collision.EnableBoundsChecks
#Overview
name: p.Chaos.Collision.EnableBoundsChecks
This variable is created as a Console Variable (cvar).
- type:
Var
- help: ``
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.Collision.EnableBoundsChecks is to control whether bounding box checks are enabled in the Chaos physics system’s collision detection process. This setting variable is part of the collision system within Unreal Engine’s Chaos physics framework.
The Unreal Engine subsystem that relies on this setting variable is the Chaos physics engine, specifically its collision detection module. This can be seen from the file path and namespace where the variable is defined and used.
The value of this variable is set through the Unreal Engine console variable system. It’s initialized to true by default, as seen in the source code:
bool bChaos_Collision_EnableBoundsChecks = true;
FAutoConsoleVariableRef CVarChaos_Collision_EnableBoundsChecks(TEXT("p.Chaos.Collision.EnableBoundsChecks"), bChaos_Collision_EnableBoundsChecks, TEXT(""));
This variable interacts with the bChaos_Collision_EnableBoundsChecks
boolean variable. They share the same value, with the console variable controlling the boolean’s state.
Developers must be aware that this variable affects the performance and accuracy of collision detection. Enabling bounds checks can improve performance by quickly ruling out collisions between objects that are far apart, but it might miss some edge cases if objects are moving very quickly.
Best practices when using this variable include:
- Keep it enabled (default) for most scenarios to benefit from performance optimizations.
- Consider disabling it if you notice missed collisions between fast-moving objects.
- Profile your game’s performance with this option both enabled and disabled to determine the best setting for your specific use case.
Regarding the associated variable bChaos_Collision_EnableBoundsChecks
:
The purpose of this boolean variable is to provide a quick, in-code way to check if bounds checks are enabled. It’s used directly in collision detection logic, as seen in the CalculateImplicitBoundsTestFlags
function.
This variable is set by the console variable system and is used throughout the Chaos collision detection code. It doesn’t interact with other variables beyond its relationship with the console variable.
Developers should be aware that changing this variable’s value directly in code won’t have an effect unless the console variable is also updated. Always use the console variable to modify this setting.
Best practices for this variable include:
- Treat it as read-only in most cases, relying on the console variable to modify its value.
- Use it in performance-critical code paths where checking the console variable directly might be too costly.
#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/PBDCollisionConstraint.cpp:65
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
bool bChaos_Collision_EnableBoundsChecks = true;
FAutoConsoleVariableRef CVarChaos_Collision_EnableBoundsChecks(TEXT("p.Chaos.Collision.EnableBoundsChecks"), bChaos_Collision_EnableBoundsChecks, TEXT(""));
// Maximum number of manifold points per contact (-1 for unlimited)
int32 Chaos_Collision_MaxManifoldPoints = -1;
FAutoConsoleVariableRef CVarChaos_Collision_MaxManifoldPoints(TEXT("p.Chaos.Collision.MaxManifoldPoints"), Chaos_Collision_MaxManifoldPoints, TEXT(""));
#Associated Variable and Callsites
This variable is associated with another variable named bChaos_Collision_EnableBoundsChecks
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/PBDCollisionConstraint.cpp:64
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
FAutoConsoleVariableRef CVarChaos_Collision_OneWayStiffness(TEXT("p.Chaos.Collision.OneWayStiffness"), Chaos_Collision_OneWayStiffness, TEXT("Collision solver stiffnes for one-way interactions"));
bool bChaos_Collision_EnableBoundsChecks = true;
FAutoConsoleVariableRef CVarChaos_Collision_EnableBoundsChecks(TEXT("p.Chaos.Collision.EnableBoundsChecks"), bChaos_Collision_EnableBoundsChecks, TEXT(""));
// Maximum number of manifold points per contact (-1 for unlimited)
int32 Chaos_Collision_MaxManifoldPoints = -1;
FAutoConsoleVariableRef CVarChaos_Collision_MaxManifoldPoints(TEXT("p.Chaos.Collision.MaxManifoldPoints"), Chaos_Collision_MaxManifoldPoints, TEXT(""));
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Collision/CollisionUtil.h:7
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
namespace Chaos
{
extern bool bChaos_Collision_EnableBoundsChecks;
extern bool bChaos_Collision_EnableLargeMeshManifolds;
namespace Private
{
// Get the implicit object type for the implicit object on the particle, taking into account the fact that the implicit
// may be set to use a LevelSet, but only if the particle has collision particles
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Collision/CollisionUtil.h:57
Scope (from outer to inner):
file
namespace Chaos
namespace Private
function inline FImplicitBoundsTestFlags CalculateImplicitBoundsTestFlags
Source code excerpt:
const bool bHasBounds0 = (Implicit0 != nullptr) && Implicit0->HasBoundingBox();
const bool bHasBounds1 = (Implicit1 != nullptr) && Implicit1->HasBoundingBox();
const bool bAllowBoundsCheck = bChaos_Collision_EnableBoundsChecks && bHasBounds0 && bHasBounds1;
Flags.bEnableAABBCheck = bAllowBoundsCheck && !(bIsSphere0 && bIsSphere1); // No AABB test if both are spheres
Flags.bEnableOBBCheck0 = bAllowBoundsCheck && !bIsSphere0; // No OBB test for spheres
Flags.bEnableOBBCheck1 = bAllowBoundsCheck && !bIsSphere1; // No OBB test for spheres
Flags.bEnableDistanceCheck = bAllowBoundsCheck && bIsSphere0 && bIsSphere1; // Simple distance test for sphere pairs