p.Chaos.Solver.Collision.DeferNarrowPhase
p.Chaos.Solver.Collision.DeferNarrowPhase
#Overview
name: p.Chaos.Solver.Collision.DeferNarrowPhase
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Create contacts for all broadphase pairs, perform NarrowPhase later.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.Solver.Collision.DeferNarrowPhase is to control whether the Chaos physics solver defers the narrow phase collision detection in its collision pipeline. This setting is part of the collision detection system within Unreal Engine’s Chaos physics engine.
This setting variable is primarily used in the Chaos physics subsystem, specifically within the PBDRigidsSolver module. Based on the callsites, it’s clear that this variable is utilized in the collision detection process of the physics solver.
The value of this variable is set through a console variable (CVar) system, which allows for runtime modification. It’s initialized to 0 by default, meaning narrow phase collision detection is not deferred by default.
The associated variable ChaosSolverCollisionDeferNarrowPhase directly interacts with p.Chaos.Solver.Collision.DeferNarrowPhase. They share the same value and are used interchangeably in the code.
Developers must be aware that enabling this setting (setting it to a non-zero value) will change the order of operations in the collision detection pipeline. When enabled, it will create contacts for all broadphase pairs first and perform the narrow phase later. This can have implications on performance and accuracy of collision detection.
Best practices when using this variable include:
- Understanding the performance implications of deferring narrow phase collision detection in your specific use case.
- Testing thoroughly with both enabled and disabled states to ensure desired behavior and performance.
- Considering the trade-offs between immediate and deferred narrow phase detection based on the specific requirements of your game or simulation.
Regarding the associated variable ChaosSolverCollisionDeferNarrowPhase: The purpose of ChaosSolverCollisionDeferNarrowPhase is to serve as the actual storage for the p.Chaos.Solver.Collision.DeferNarrowPhase setting. It’s an integer variable that directly controls whether narrow phase collision detection is deferred.
This variable is used within the Chaos physics solver, specifically in the PrepareAdvanceBy function of the FPBDRigidsSolver class. It’s used to configure the collision detector settings before advancing the physics simulation.
The value of ChaosSolverCollisionDeferNarrowPhase is set through the console variable system and can be modified at runtime.
It interacts directly with the p.Chaos.Solver.Collision.DeferNarrowPhase console variable, and its value is used to set the bDeferNarrowPhase member of the FCollisionDetectorSettings struct.
Developers should be aware that this variable directly affects the behavior of the physics solver. A non-zero value will enable deferred narrow phase collision detection, which can impact both performance and accuracy of collision detection.
Best practices for using this variable include:
- Modifying it through the console variable system rather than directly, to ensure consistency with the p.Chaos.Solver.Collision.DeferNarrowPhase setting.
- Considering the implications on physics simulation behavior when changing this value.
- Testing thoroughly with different values to understand the impact on your specific use case.
#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:362
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
int32 ChaosSolverCollisionDeferNarrowPhase = 0;
FAutoConsoleVariableRef CVarChaosSolverCollisionDeferNarrowPhase(TEXT("p.Chaos.Solver.Collision.DeferNarrowPhase"), ChaosSolverCollisionDeferNarrowPhase, TEXT("Create contacts for all broadphase pairs, perform NarrowPhase later."));
// Allow one-shot or incremental manifolds where supported (which depends on shape pair types)
int32 ChaosSolverCollisionUseManifolds = 1;
FAutoConsoleVariableRef CVarChaosSolverCollisionUseManifolds(TEXT("p.Chaos.Solver.Collision.UseManifolds"), ChaosSolverCollisionUseManifolds, TEXT("Enable/Disable use of manifolds in collision."));
// Allow manifolds to be reused between ticks
#Associated Variable and Callsites
This variable is associated with another variable named ChaosSolverCollisionDeferNarrowPhase
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:361
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
FAutoConsoleVariableRef CVarChaosSolverCleanupCommandsOnDestruction(TEXT("p.Chaos.Solver.CleanupCommandsOnDestruction"), ChaosSolverCleanupCommandsOnDestruction, TEXT("Whether or not to run internal command queue cleanup on solver destruction (0 = no cleanup, >0 = cleanup all commands)"));
int32 ChaosSolverCollisionDeferNarrowPhase = 0;
FAutoConsoleVariableRef CVarChaosSolverCollisionDeferNarrowPhase(TEXT("p.Chaos.Solver.Collision.DeferNarrowPhase"), ChaosSolverCollisionDeferNarrowPhase, TEXT("Create contacts for all broadphase pairs, perform NarrowPhase later."));
// Allow one-shot or incremental manifolds where supported (which depends on shape pair types)
int32 ChaosSolverCollisionUseManifolds = 1;
FAutoConsoleVariableRef CVarChaosSolverCollisionUseManifolds(TEXT("p.Chaos.Solver.Collision.UseManifolds"), ChaosSolverCollisionUseManifolds, TEXT("Enable/Disable use of manifolds in collision."));
// Allow manifolds to be reused between ticks
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PBDRigidsSolver.cpp:1285
Scope (from outer to inner):
file
namespace Chaos
function void FPBDRigidsSolver::PrepareAdvanceBy
Source code excerpt:
FCollisionDetectorSettings CollisionDetectorSettings = MEvolution->GetCollisionConstraints().GetDetectorSettings();
CollisionDetectorSettings.bAllowManifoldReuse = (ChaosSolverCollisionAllowManifoldUpdate != 0);
CollisionDetectorSettings.bDeferNarrowPhase = (ChaosSolverCollisionDeferNarrowPhase != 0);
CollisionDetectorSettings.bAllowManifolds = (ChaosSolverCollisionUseManifolds != 0);
CollisionDetectorSettings.bAllowCCD = bChaosUseCCD;
CollisionDetectorSettings.bAllowMACD = bChaosUseMACD;
MEvolution->GetCollisionConstraints().SetDetectorSettings(CollisionDetectorSettings);
FPBDJointSolverSettings JointsSettings = MEvolution->GetJointConstraints().GetSettings();