p.Chaos.Collision.MarginMax

p.Chaos.Collision.MarginMax

#Overview

name: p.Chaos.Collision.MarginMax

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.MarginMax is to override the maximum collision margin set in the Physics Settings for the Chaos physics engine in Unreal Engine 5.

This setting variable is primarily used by the Chaos physics engine, which is part of Unreal Engine’s physics system. Based on the callsites, it’s evident that this variable is utilized within the ChaosInterface namespace, specifically in the PhysicsEngine/Experimental module.

The value of this variable is set through a console variable (cvar) system, as indicated by the FAutoConsoleVariableRef declaration. This allows developers to modify the value at runtime or through configuration files.

The associated variable Chaos_Collision_MarginMax interacts directly with p.Chaos.Collision.MarginMax. They share the same value, with Chaos_Collision_MarginMax being the actual float variable used in the code.

Developers must be aware that this variable only takes effect when its value is greater than or equal to 0. A negative value (-1.0f by default) indicates that the override is not active, and the engine will use the value set in the Physics Settings instead.

Best practices when using this variable include:

  1. Only modify it when you need to fine-tune collision behavior that can’t be achieved through the standard Physics Settings.
  2. Be cautious when changing this value, as it can significantly impact collision detection and performance.
  3. Use it in conjunction with p.Chaos.Collision.MarginFraction for comprehensive control over collision margins.
  4. Remember to reset it to -1.0f if you want to revert to using the Physics Settings value.

Regarding the associated variable Chaos_Collision_MarginMax:

#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:30

Scope (from outer to inner):

file
namespace    ChaosInterface

Source code excerpt:


	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>
	TArray<Chaos::TVec3<int32>> GetMeshElements(const PHYSX_MESH* PhysXMesh)
	{
		check(false);

#Associated Variable and Callsites

This variable is associated with another variable named Chaos_Collision_MarginMax. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/Experimental/ChaosInterfaceUtils.cpp:29

Scope (from outer to inner):

file
namespace    ChaosInterface

Source code excerpt:

	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>
	TArray<Chaos::TVec3<int32>> GetMeshElements(const PHYSX_MESH* PhysXMesh)
	{
		check(false);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/Experimental/ChaosInterfaceUtils.cpp:82

Scope (from outer to inner):

file
namespace    ChaosInterface
function     void CreateGeometry

Source code excerpt:

			CollisionMarginFraction = Chaos_Collision_MarginFraction;
		}
		if (Chaos_Collision_MarginMax >= 0.0f)
		{
			CollisionMarginMax = Chaos_Collision_MarginMax;
		}

		// Complex as simple should not create simple geometry, unless there is no complex geometry.  Otherwise both get queried against.
		const bool bMakeSimpleGeometry = (CollisionTraceType != CTF_UseComplexAsSimple) || (InParams.TriMeshGeometries.Num() == 0);

		// The reverse is true for Simple as Complex.