p.Chaos.Solver.OneWayPairCollisionMode
p.Chaos.Solver.OneWayPairCollisionMode
#Overview
name: p.Chaos.Solver.OneWayPairCollisionMode
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
How to treat collisions between two one-way interaction particles. See EOneWayInteractionPairCollisionMode (0: Ignore collisions; 1: Collide as normal; 2: Collide as spheres)
It is referenced in 8
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.Solver.OneWayPairCollisionMode is to control how collisions between two one-way interaction particles are treated in the Chaos physics system of Unreal Engine 5. This setting variable is part of the Chaos physics solver, which is an experimental feature in UE5.
This setting variable is primarily used in the Chaos physics module, specifically in the collision detection and handling system. Based on the callsites, it’s evident that this variable affects the behavior of the PBDRigidsEvolutionGBF (Position Based Dynamics Rigid Body Evolution) and the particle pair mid-phase collision detection.
The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through console commands. It’s initialized with the value of EOneWayInteractionPairCollisionMode::SphereCollision.
The associated variable ChaosOneWayInteractionPairCollisionMode interacts directly with p.Chaos.Solver.OneWayPairCollisionMode. They share the same value and are used interchangeably in the code.
Developers must be aware that this variable affects the collision behavior of one-way interaction particles. It can be set to three different modes: 0: Ignore collisions 1: Collide as normal 2: Collide as spheres (default)
Best practices when using this variable include:
- Understanding the implications of each mode on physics performance and accuracy.
- Testing thoroughly when changing this setting, as it can significantly affect the behavior of one-way interaction particles.
- Considering the trade-offs between performance and accuracy when choosing a mode.
Regarding the associated variable ChaosOneWayInteractionPairCollisionMode:
The purpose of ChaosOneWayInteractionPairCollisionMode is to provide an internal representation of the p.Chaos.Solver.OneWayPairCollisionMode setting. It’s used throughout the Chaos physics code to determine how to handle collisions between one-way interaction particles.
This variable is used in various parts of the Chaos physics system, including debug drawing, particle pair mid-phase collision detection, and the spatial acceleration broad phase.
The value of this variable is set by the p.Chaos.Solver.OneWayPairCollisionMode console variable.
Developers should be aware that this variable directly affects the physics simulation behavior and should be used consistently with p.Chaos.Solver.OneWayPairCollisionMode.
Best practices for using this variable include:
- Accessing it through the CVars namespace to ensure consistency.
- Using the EOneWayInteractionPairCollisionMode enum for comparisons rather than raw integer values to improve code readability and maintainability.
- Being cautious when modifying its value, as it can have wide-ranging effects on the physics simulation.
#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:131
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
// See EOneWayInteractionPairCollisionMode
int32 ChaosOneWayInteractionPairCollisionMode = (int32)EOneWayInteractionPairCollisionMode::SphereCollision;
FAutoConsoleVariableRef CVarChaosIgnoreOneWayPairCollisions(TEXT("p.Chaos.Solver.OneWayPairCollisionMode"), ChaosOneWayInteractionPairCollisionMode, TEXT("How to treat collisions between two one-way interaction particles. See EOneWayInteractionPairCollisionMode (0: Ignore collisions; 1: Collide as normal; 2: Collide as spheres)"));
DECLARE_CYCLE_STAT(TEXT("FPBDRigidsEvolutionGBF::AdvanceOneTimeStep"), STAT_Evolution_AdvanceOneTimeStep, STATGROUP_Chaos);
DECLARE_CYCLE_STAT(TEXT("FPBDRigidsEvolutionGBF::UnclusterUnions"), STAT_Evolution_UnclusterUnions, STATGROUP_Chaos);
DECLARE_CYCLE_STAT(TEXT("FPBDRigidsEvolutionGBF::Integrate"), STAT_Evolution_Integrate, STATGROUP_Chaos);
DECLARE_CYCLE_STAT(TEXT("FPBDRigidsEvolutionGBF::KinematicTargets"), STAT_Evolution_KinematicTargets, STATGROUP_Chaos);
#Associated Variable and Callsites
This variable is associated with another variable named ChaosOneWayInteractionPairCollisionMode
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ChaosDebugDraw.cpp:37
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
namespace CVars
{
extern int32 ChaosOneWayInteractionPairCollisionMode;
}
namespace DebugDraw
{
bool bChaosDebugDebugDrawShapeBounds = false;
FAutoConsoleVariableRef CVarChaosDebugDrawShapeBounds(TEXT("p.Chaos.DebugDraw.ShowShapeBounds"), bChaosDebugDebugDrawShapeBounds, TEXT("Whether to show the bounds of each shape in DrawShapes"));
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ChaosDebugDraw.cpp:1387
Scope (from outer to inner):
file
namespace Chaos
namespace DebugDraw
function void DrawCollisionImpl
Source code excerpt:
// Show the sphere approximation if enabled
//if ((CVars::ChaosOneWayInteractionPairCollisionMode == (int32)EOneWayInteractionPairCollisionMode::SphereCollision) && Particle0->OneWayInteraction() && Particle1->OneWayInteraction())
//{
// DrawShape(Contact.GetShapeWorldTransform0(), Contact.GetImplicit0(), nullptr, FColor::Green, 0, &Settings);
// DrawShape(Contact.GetShapeWorldTransform1(), Contact.GetImplicit1(), nullptr, FColor::Green, 0, &Settings);
//}
}
if (Settings.ContactOwnerWidth > 0)
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/ParticlePairMidPhase.cpp:62
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
FAutoConsoleVariableRef CVarChaos_Collision_MaxShapePairs(TEXT("p.Chaos.Collision.MaxShapePairs"), Chaos_Collision_MidPhase_MaxShapePairs, TEXT(""));
extern int32 ChaosOneWayInteractionPairCollisionMode;
extern bool bChaosForceMACD;
}
using namespace CVars;
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/ParticlePairMidPhase.cpp:777
Scope (from outer to inner):
file
namespace Chaos
function EParticlePairMidPhaseType FParticlePairMidPhase::CalculateMidPhaseType
Source code excerpt:
// If both particles have one-way interaction enabled, we might want to treat them as spheres
if (bCanPrebuildShapePairs && (CVars::ChaosOneWayInteractionPairCollisionMode == (int32)EOneWayInteractionPairCollisionMode::SphereCollision))
{
const bool bIsOneWay0 = FConstGenericParticleHandle(InParticle0)->OneWayInteraction();
const bool bIsOneWay1 = FConstGenericParticleHandle(InParticle1)->OneWayInteraction();
if (bIsOneWay0 && bIsOneWay1)
{
return EParticlePairMidPhaseType::SphereApproximation;
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidsEvolutionGBF.cpp:130
Scope (from outer to inner):
file
namespace Chaos
namespace CVars
Source code excerpt:
// Determines what happens when two one-way particles collide
// See EOneWayInteractionPairCollisionMode
int32 ChaosOneWayInteractionPairCollisionMode = (int32)EOneWayInteractionPairCollisionMode::SphereCollision;
FAutoConsoleVariableRef CVarChaosIgnoreOneWayPairCollisions(TEXT("p.Chaos.Solver.OneWayPairCollisionMode"), ChaosOneWayInteractionPairCollisionMode, TEXT("How to treat collisions between two one-way interaction particles. See EOneWayInteractionPairCollisionMode (0: Ignore collisions; 1: Collide as normal; 2: Collide as spheres)"));
DECLARE_CYCLE_STAT(TEXT("FPBDRigidsEvolutionGBF::AdvanceOneTimeStep"), STAT_Evolution_AdvanceOneTimeStep, STATGROUP_Chaos);
DECLARE_CYCLE_STAT(TEXT("FPBDRigidsEvolutionGBF::UnclusterUnions"), STAT_Evolution_UnclusterUnions, STATGROUP_Chaos);
DECLARE_CYCLE_STAT(TEXT("FPBDRigidsEvolutionGBF::Integrate"), STAT_Evolution_Integrate, STATGROUP_Chaos);
DECLARE_CYCLE_STAT(TEXT("FPBDRigidsEvolutionGBF::KinematicTargets"), STAT_Evolution_KinematicTargets, STATGROUP_Chaos);
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Collision/SpatialAccelerationBroadPhase.h:23
Scope (from outer to inner):
file
namespace Chaos::CVars
Source code excerpt:
{
extern bool bChaosMidPhaseRedistributionEnabled;
extern int32 ChaosOneWayInteractionPairCollisionMode;
}
namespace Chaos
{
template <typename TPayloadType, typename T, int d>
class ISpatialAcceleration;
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Collision/SpatialAccelerationBroadPhase.h:680
Scope (from outer to inner):
file
namespace Chaos
class class FSpatialAccelerationBroadPhase
function void AssignMidPhases
Source code excerpt:
if (Overlap.bCollisionsEnabled)
{
if (CVars::ChaosOneWayInteractionPairCollisionMode == (int32)EOneWayInteractionPairCollisionMode::IgnoreCollision)
{
const bool bIsOneWay0 = FConstGenericParticleHandle(Overlap.Particles[0])->OneWayInteraction();
const bool bIsOneWay1 = FConstGenericParticleHandle(Overlap.Particles[1])->OneWayInteraction();
if (bIsOneWay0 && bIsOneWay1)
{
continue;