p.Chaos.TriangleIntersections.MaxDelta

p.Chaos.TriangleIntersections.MaxDelta

#Overview

name: p.Chaos.TriangleIntersections.MaxDelta

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.TriangleIntersections.MaxDelta is to control the maximum delta position applied to resolve triangle intersections in the Chaos physics system of Unreal Engine 5.

This setting variable is primarily used in the Chaos physics subsystem, specifically within the triangle mesh collision resolution component. It’s part of the Experimental Chaos module, which is responsible for soft body dynamics and collision handling.

The value of this variable is set through an FAutoConsoleVariableRef, which means it can be adjusted at runtime through the console or configuration files. The default value is 0.01f.

The associated variable Chaos_TriangleIntersections_MaxDelta directly interacts with p.Chaos.TriangleIntersections.MaxDelta. They share the same value, with Chaos_TriangleIntersections_MaxDelta being the actual float variable used in the code, while p.Chaos.TriangleIntersections.MaxDelta is the console variable name.

Developers must be aware that this variable directly affects the behavior of triangle intersection resolution in soft body simulations. A higher value may result in more aggressive resolution of intersections, potentially leading to instability, while a lower value may result in slower or incomplete resolution of intersections.

Best practices when using this variable include:

  1. Start with the default value (0.01f) and adjust gradually if needed.
  2. Monitor the simulation for any instabilities or visual artifacts when changing this value.
  3. Consider the scale of your simulation when adjusting this value, as it represents a world-space distance.
  4. Use in conjunction with other Chaos physics settings for optimal results.

Regarding the associated variable Chaos_TriangleIntersections_MaxDelta:

The purpose of Chaos_TriangleIntersections_MaxDelta is to store the actual float value used in the code for the maximum delta position in triangle intersection resolution.

This variable is used directly in the Chaos physics subsystem, specifically in the FPBDTriangleMeshIntersections::Apply function within the Chaos::Softs namespace.

The value of Chaos_TriangleIntersections_MaxDelta is set by the console variable p.Chaos.TriangleIntersections.MaxDelta.

It interacts directly with the GetDelta function, which calculates the delta position to be applied for resolving triangle intersections.

Developers should be aware that modifying Chaos_TriangleIntersections_MaxDelta directly in the code is not recommended, as its value is intended to be controlled through the console variable.

Best practices for Chaos_TriangleIntersections_MaxDelta include:

  1. Use the console variable p.Chaos.TriangleIntersections.MaxDelta to modify its value rather than changing it directly in the code.
  2. When debugging, you can add a watch on this variable to monitor its current value during runtime.
  3. Consider the performance implications of very small or very large values 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/PBDTriangleMeshIntersections.cpp:4

Scope: file

Source code excerpt:


float Chaos_TriangleIntersections_MaxDelta = 0.01f;
FAutoConsoleVariableRef CVarChaosTriangleIntersectionMaxImpulse(TEXT("p.Chaos.TriangleIntersections.MaxDelta"), Chaos_TriangleIntersections_MaxDelta, TEXT("Maximum delta position applied to resolve triangle intersections."));

namespace Chaos::Softs {

static inline FSolverVec3 GetDelta(const FPBDTriangleMeshCollisions::FContourMinimizationIntersection& Intersection, const FSolverReal MaxDelta, const FSolverReal RegularizeEpsilonSq)
{
	// Using pre-calculated "GlobalGradientVector". Whether this is actually globally calculated or a copy of the local gradient depends on settings in PBDTriangleMeshCollisions (default is global)

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDTriangleMeshIntersections.cpp:3

Scope: file

Source code excerpt:

#include "Chaos/SoftsSolverParticlesRange.h"

float Chaos_TriangleIntersections_MaxDelta = 0.01f;
FAutoConsoleVariableRef CVarChaosTriangleIntersectionMaxImpulse(TEXT("p.Chaos.TriangleIntersections.MaxDelta"), Chaos_TriangleIntersections_MaxDelta, TEXT("Maximum delta position applied to resolve triangle intersections."));

namespace Chaos::Softs {

static inline FSolverVec3 GetDelta(const FPBDTriangleMeshCollisions::FContourMinimizationIntersection& Intersection, const FSolverReal MaxDelta, const FSolverReal RegularizeEpsilonSq)
{
	// Using pre-calculated "GlobalGradientVector". Whether this is actually globally calculated or a copy of the local gradient depends on settings in PBDTriangleMeshCollisions (default is global)

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDTriangleMeshIntersections.cpp:25

Scope (from outer to inner):

file
namespace    Chaos::Softs
function     void FPBDTriangleMeshIntersections::Apply

Source code excerpt:

	for( const FPBDTriangleMeshCollisions::FContourMinimizationIntersection& Intersection : Intersections )
	{
		const FSolverVec3 Delta = GetDelta(Intersection, Chaos_TriangleIntersections_MaxDelta, RegularizeEpsilonSq);
		if (Particles.InvM(Intersection.EdgeVertices[0]) > 0)
		{
			Particles.P(Intersection.EdgeVertices[0]) += Delta;
		}
		if (Particles.InvM(Intersection.EdgeVertices[1]) > 0)
		{