p.Chaos.Collision.EnableOneWayInteraction
p.Chaos.Collision.EnableOneWayInteraction
#Overview
name: p.Chaos.Collision.EnableOneWayInteraction
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether the one-way interaction flag is respected in collision constraints
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.Collision.EnableOneWayInteraction is to control the one-way interaction system for collisions in the Chaos physics engine of Unreal Engine 5.
This setting variable is primarily used by the Chaos physics engine, specifically in the collision handling subsystem. It is part of the Experimental Chaos module, which is an advanced physics simulation system in Unreal Engine 5.
The value of this variable is set to true by default, as seen in the source code. It can be modified at runtime through the console variable system, allowing developers to enable or disable the one-way interaction feature dynamically.
The associated variable bChaos_Collision_EnableOneWayInteraction directly interacts with p.Chaos.Collision.EnableOneWayInteraction. They share the same value, with bChaos_Collision_EnableOneWayInteraction being the actual boolean variable used in the code logic.
Developers must be aware that this variable affects how collision constraints are respected in the physics simulation. When enabled, it allows for one-way interactions between objects, which can be useful for creating specific physics behaviors.
Best practices when using this variable include:
- Understanding the implications of one-way interactions in your physics simulations.
- Testing your game thoroughly with both enabled and disabled states to ensure desired behavior.
- Considering performance impacts, as one-way interactions may require additional computational resources.
Regarding the associated variable bChaos_Collision_EnableOneWayInteraction:
- Its purpose is to serve as the internal boolean flag for the one-way interaction system.
- It is used directly in the physics code, specifically in the UpdateMassScales function of the FPBDCollisionConstraint class.
- The value is set through the console variable system, allowing for runtime modification.
- It interacts closely with the Flags.bIsOneWayInteraction flag and individual particle properties.
- Developers should be aware that this variable directly affects mass scaling in collision constraints, which can significantly impact physics behavior.
- Best practices include careful consideration of one-way interactions in physics-heavy scenes and thorough testing of different scenarios.
#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:56
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
// Enable/Disable the one-way interaction system for collisions
bool bChaos_Collision_EnableOneWayInteraction = true;
FAutoConsoleVariableRef CVarChaos_Collision_EnableOneWayInteraction(TEXT("p.Chaos.Collision.EnableOneWayInteraction"), bChaos_Collision_EnableOneWayInteraction, TEXT("Whether the one-way interaction flag is respected in collision constraints"));
// The stiffness used for collision between one-way objects and other dynamic objects. The stiffness against kinematics and statics is not affected. A value of less than 1
// will treat collisions with the static scene as "harder" than collisions with dynamics which will prevent one-way objects from getting squeezed out of the world when a dynamic
// lands on top of them. Instead, they will stay on top of the terrain and sink into the dynamic.
FRealSingle Chaos_Collision_OneWayStiffness = 0.5f;
FAutoConsoleVariableRef CVarChaos_Collision_OneWayStiffness(TEXT("p.Chaos.Collision.OneWayStiffness"), Chaos_Collision_OneWayStiffness, TEXT("Collision solver stiffnes for one-way interactions"));
#Associated Variable and Callsites
This variable is associated with another variable named bChaos_Collision_EnableOneWayInteraction
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/PBDCollisionConstraint.cpp:55
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
// Enable/Disable the one-way interaction system for collisions
bool bChaos_Collision_EnableOneWayInteraction = true;
FAutoConsoleVariableRef CVarChaos_Collision_EnableOneWayInteraction(TEXT("p.Chaos.Collision.EnableOneWayInteraction"), bChaos_Collision_EnableOneWayInteraction, TEXT("Whether the one-way interaction flag is respected in collision constraints"));
// The stiffness used for collision between one-way objects and other dynamic objects. The stiffness against kinematics and statics is not affected. A value of less than 1
// will treat collisions with the static scene as "harder" than collisions with dynamics which will prevent one-way objects from getting squeezed out of the world when a dynamic
// lands on top of them. Instead, they will stay on top of the terrain and sink into the dynamic.
FRealSingle Chaos_Collision_OneWayStiffness = 0.5f;
FAutoConsoleVariableRef CVarChaos_Collision_OneWayStiffness(TEXT("p.Chaos.Collision.OneWayStiffness"), Chaos_Collision_OneWayStiffness, TEXT("Collision solver stiffnes for one-way interactions"));
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Collision/PBDCollisionConstraint.cpp:481
Scope (from outer to inner):
file
namespace Chaos
function void FPBDCollisionConstraint::UpdateMassScales
Source code excerpt:
void FPBDCollisionConstraint::UpdateMassScales()
{
if (Flags.bIsOneWayInteraction && bChaos_Collision_EnableOneWayInteraction)
{
const bool bOneWay0 = FConstGenericParticleHandle(GetParticle0())->OneWayInteraction();
const bool bOneWay1 = FConstGenericParticleHandle(GetParticle1())->OneWayInteraction();
if (bOneWay0 && !bOneWay1)
{
Material.InvMassScale1 = 0;