p.Chaos.Collision.MarginFraction

p.Chaos.Collision.MarginFraction

#Overview

name: p.Chaos.Collision.MarginFraction

This variable is created as a Console Variable (cvar).

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:

  1. Only use it for debugging or fine-tuning physics behavior, as it overrides the global settings.
  2. Be cautious when changing it at runtime, as it could significantly impact physics performance and behavior.
  3. Consider using it in conjunction with p.Chaos.Collision.MarginMax for comprehensive control over collision margins.

Regarding the associated variable Chaos_Collision_MarginFraction:

#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;
		}