p.Chaos.Convex.SplittingThreshold

p.Chaos.Convex.SplittingThreshold

#Overview

name: p.Chaos.Convex.SplittingThreshold

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.Convex.SplittingThreshold is to control the threshold for triggering volume splitting during tree construction in the Chaos physics engine’s convex hull optimization process.

This setting variable is used in the Chaos physics engine, which is part of Unreal Engine’s experimental physics system. Specifically, it’s utilized in the convex optimization module of the Chaos system.

The value of this variable is set through the Unreal Engine console variable system. It’s defined as a float with an initial value of 1.0f.

The associated variable ChaosConvexSplittingThreshold directly interacts with p.Chaos.Convex.SplittingThreshold. They share the same value, with ChaosConvexSplittingThreshold being the actual variable used in the code logic.

Developers must be aware that this variable affects the performance and accuracy of convex hull optimization in the Chaos physics engine. A lower threshold will result in more frequent splitting, potentially leading to more accurate but more complex convex hulls. Conversely, a higher threshold will lead to less splitting, potentially resulting in simpler but less accurate convex hulls.

Best practices when using this variable include:

  1. Adjusting it based on the specific needs of your project, balancing between performance and accuracy.
  2. Testing different values to find the optimal setting for your particular use case.
  3. Considering the impact on both runtime performance and memory usage, as more complex convex hulls can affect both.

Regarding the associated variable ChaosConvexSplittingThreshold:

The purpose of ChaosConvexSplittingThreshold is to serve as the in-code representation of the p.Chaos.Convex.SplittingThreshold console variable.

This variable is used directly in the Chaos physics engine’s convex optimization logic, specifically in the MergeConnectedShapes function of the FConvexOptimizer class.

The value of this variable is set by the console variable system when p.Chaos.Convex.SplittingThreshold is modified.

It interacts directly with the physics calculations, being compared against a volume ratio to determine whether to split or merge convex shapes.

Developers should be aware that modifying p.Chaos.Convex.SplittingThreshold will directly affect this variable and, consequently, the behavior of the convex optimization process.

Best practices include monitoring the performance impact of different threshold values and adjusting based on the specific requirements of the project’s physics simulations.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

	// Tribox volume / convex hull threshold to trigger a volume splitting during tree construction
	float ChaosConvexSplittingThreshold = 1.0f;
	FAutoConsoleVariableRef CVarChaosConvexSplittingThreshold(TEXT("p.Chaos.Convex.SplittingThreshold"), ChaosConvexSplittingThreshold, TEXT("Tribox volume / convex hull threshold to trigger a volume splitting during tree construction"));

	// Min volume of the simplified convexes
	float ChaosConvexMinVolume = 10000.0f;
	FAutoConsoleVariableRef CVarChaosConvexMinVolume(TEXT("p.Chaos.Convex.MinVolume"), ChaosConvexMinVolume, TEXT("Min volume of the simplified convexes"));

	// Boolean to check if we are merging (bottom-up) or splitting (top-bottom) the convexes 

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ConvexOptimizer.cpp:24

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

	
	// Tribox volume / convex hull threshold to trigger a volume splitting during tree construction
	float ChaosConvexSplittingThreshold = 1.0f;
	FAutoConsoleVariableRef CVarChaosConvexSplittingThreshold(TEXT("p.Chaos.Convex.SplittingThreshold"), ChaosConvexSplittingThreshold, TEXT("Tribox volume / convex hull threshold to trigger a volume splitting during tree construction"));

	// Min volume of the simplified convexes
	float ChaosConvexMinVolume = 10000.0f;
	FAutoConsoleVariableRef CVarChaosConvexMinVolume(TEXT("p.Chaos.Convex.MinVolume"), ChaosConvexMinVolume, TEXT("Min volume of the simplified convexes"));

	// Boolean to check if we are merging (bottom-up) or splitting (top-bottom) the convexes 

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/ConvexOptimizer.cpp:433

Scope (from outer to inner):

file
function     void FConvexOptimizer::MergeConnectedShapes

Source code excerpt:


								const FTribox::FRealType VolumeRatio = LocalTribox.ComputeVolume() / (CurrentNode->NodeVolume + OtherNode->NodeVolume);
								if (VolumeRatio < CVars::ChaosConvexSplittingThreshold)
								{
									CurrentNode->NodeTribox += OtherNode->NodeTribox;
									CurrentNode->NodeVolume += OtherNode->NodeVolume;

									NodeQueue.Add(EdgeOtherNode);
									OtherNode->bValidNode = false;