p.Chaos.Convex.DynamicMode

p.Chaos.Convex.DynamicMode

#Overview

name: p.Chaos.Convex.DynamicMode

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.DynamicMode is to control the simplification mode for dynamic shapes in the Chaos physics system of Unreal Engine 5. This setting variable is part of the collision detection and physics simulation subsystem, specifically for handling convex shapes in dynamic objects.

The Chaos physics module in Unreal Engine 5 relies on this setting variable. It’s used within the ConvexOptimizer component of the Chaos namespace, which is responsible for optimizing and simplifying convex shapes for physics simulations.

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

The associated variable ChaosConvexDynamicMode interacts directly with p.Chaos.Convex.DynamicMode. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable affects how dynamic shapes are simplified for physics calculations. The variable accepts three modes: 0: Single Convex 1: One convex per children 2: Merge connected children using the splitting threshold

The choice of mode can significantly impact performance and accuracy of physics simulations for dynamic objects.

Best practices when using this variable include:

  1. Consider the trade-off between performance and accuracy when choosing a mode.
  2. Test different modes with your specific use case to find the optimal setting.
  3. Be consistent in using either the console variable (p.Chaos.Convex.DynamicMode) or the C++ variable (ChaosConvexDynamicMode) to avoid confusion.
  4. Document any changes to this setting, as it can have wide-ranging effects on physics behavior in your game.

Regarding the associated variable ChaosConvexDynamicMode: This is an int32 variable that directly corresponds to p.Chaos.Convex.DynamicMode. It’s used in the C++ code to check the current simplification mode and determine how to process convex shapes for dynamic objects. The variable is defined in the Chaos::CVars namespace and is used in the FConvexOptimizer::SimplifyRootConvexes function to control the simplification process. Developers should treat this variable as equivalent to p.Chaos.Convex.DynamicMode and follow the same best practices and considerations.

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:

	// Max number of convex LODs used during simplification  for kinematic particles
	int32 ChaosConvexDynamicMode = 2;
	FAutoConsoleVariableRef CVarChaosConvexDynamicMode(TEXT("p.Chaos.Convex.DynamicMode"), ChaosConvexDynamicMode, TEXT("Simplification mode for the dynamic shapes (0: Single Convex, 1: One convex per children, 2: Merge connected children using the splitting threshold)"));
	
	// 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

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    CVars

Source code excerpt:


	// Max number of convex LODs used during simplification  for kinematic particles
	int32 ChaosConvexDynamicMode = 2;
	FAutoConsoleVariableRef CVarChaosConvexDynamicMode(TEXT("p.Chaos.Convex.DynamicMode"), ChaosConvexDynamicMode, TEXT("Simplification mode for the dynamic shapes (0: Single Convex, 1: One convex per children, 2: Merge connected children using the splitting threshold)"));
	
	// 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

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

Scope (from outer to inner):

file
namespace    Chaos
namespace    Private
function     void FConvexOptimizer::SimplifyRootConvexes

Source code excerpt:

		ShapesArray.Reset();

		if((UnionShapes.Num() == 1) || ((ObjectState == EObjectStateType::Dynamic) && (CVars::ChaosConvexDynamicMode == 0)) 
				|| ((ObjectState != EObjectStateType::Dynamic) && (CVars::ChaosConvexKinematicMode == 0)))
		{
			BuildSingleConvex(UnionGeometry, UnionShapes, bOptimizeConvexes);
		}
		else
		{
			const bool bEnableMerging = ((ObjectState == EObjectStateType::Dynamic) && (CVars::ChaosConvexDynamicMode == 2))
				|| ((ObjectState != EObjectStateType::Dynamic) && (CVars::ChaosConvexKinematicMode == 2));
			BuildMultipleConvex(UnionGeometry, UnionShapes, bEnableMerging, bOptimizeConvexes);
		}
	}

	if(CVars::bChaosUnionBVHEnabled)