p.Chaos.Collision.MarginFraction
p.Chaos.Collision.MarginFraction
#Overview
name: p.Chaos.Collision.MarginFraction
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Override the collision margin fraction set in Physics Settings (if >= 0)
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.Chaos.Collision.MarginFraction is to override the collision margin fraction set in Physics Settings for the Chaos physics engine in Unreal Engine 5.
This setting variable is primarily used by the Chaos physics engine subsystem, which is part of Unreal Engine’s experimental physics implementation. It’s specifically related to collision detection and response within the Chaos system.
The value of this variable is set through the console variable system in Unreal Engine. It’s defined as an FAutoConsoleVariableRef, which allows it to be changed at runtime through console commands or configuration files.
The associated variable Chaos_Collision_MarginFraction interacts directly with p.Chaos.Collision.MarginFraction. They share the same value, with Chaos_Collision_MarginFraction being the actual float variable used in the code.
Developers must be aware that this variable only takes effect if its value is greater than or equal to 0. If it’s set to a negative value, it won’t override the Physics Settings.
Best practices when using this variable include:
- Only use it for debugging or fine-tuning physics behavior, as it overrides the global settings.
- Be cautious when changing it at runtime, as it could significantly impact physics performance and behavior.
- Consider using it in conjunction with p.Chaos.Collision.MarginMax for comprehensive control over collision margins.
Regarding the associated variable Chaos_Collision_MarginFraction:
- Its purpose is to store the actual value used in the physics calculations.
- It’s used within the Chaos physics engine subsystem.
- Its value is set either by the console variable p.Chaos.Collision.MarginFraction or remains at its default of -1.0f.
- It interacts with the CreateGeometry function, where it’s used to potentially override the CollisionMarginFraction if its value is non-negative.
- Developers should be aware that this variable is internal to the Chaos system and shouldn’t be modified directly.
- Best practice is to modify this variable only through the p.Chaos.Collision.MarginFraction console variable.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/Experimental/ChaosInterfaceUtils.cpp:27
Scope (from outer to inner):
file
namespace ChaosInterface
Source code excerpt:
{
float Chaos_Collision_MarginFraction = -1.0f;
FAutoConsoleVariableRef CVarChaosCollisionMarginFraction(TEXT("p.Chaos.Collision.MarginFraction"), Chaos_Collision_MarginFraction, TEXT("Override the collision margin fraction set in Physics Settings (if >= 0)"));
float Chaos_Collision_MarginMax = -1.0f;
FAutoConsoleVariableRef CVarChaosCollisionMarginMax(TEXT("p.Chaos.Collision.MarginMax"), Chaos_Collision_MarginMax, TEXT("Override the max collision margin set in Physics Settings (if >= 0)"));
template<class PHYSX_MESH>
#Associated Variable and Callsites
This variable is associated with another variable named Chaos_Collision_MarginFraction
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/Experimental/ChaosInterfaceUtils.cpp:26
Scope (from outer to inner):
file
namespace ChaosInterface
Source code excerpt:
namespace ChaosInterface
{
float Chaos_Collision_MarginFraction = -1.0f;
FAutoConsoleVariableRef CVarChaosCollisionMarginFraction(TEXT("p.Chaos.Collision.MarginFraction"), Chaos_Collision_MarginFraction, TEXT("Override the collision margin fraction set in Physics Settings (if >= 0)"));
float Chaos_Collision_MarginMax = -1.0f;
FAutoConsoleVariableRef CVarChaosCollisionMarginMax(TEXT("p.Chaos.Collision.MarginMax"), Chaos_Collision_MarginMax, TEXT("Override the max collision margin set in Physics Settings (if >= 0)"));
template<class PHYSX_MESH>
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/Experimental/ChaosInterfaceUtils.cpp:78
Scope (from outer to inner):
file
namespace ChaosInterface
function void CreateGeometry
Source code excerpt:
// Test margins without changing physics settings
if (Chaos_Collision_MarginFraction >= 0.0f)
{
CollisionMarginFraction = Chaos_Collision_MarginFraction;
}
if (Chaos_Collision_MarginMax >= 0.0f)
{
CollisionMarginMax = Chaos_Collision_MarginMax;
}