p.MinLevelsetDimension

p.MinLevelsetDimension

#Overview

name: p.MinLevelsetDimension

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.MinLevelsetDimension is to set the minimum number of cells on a single level set axis in the Chaos physics system of Unreal Engine 5. This setting is primarily used in the rigid body clustering algorithm, which is part of the physics simulation subsystem.

The Unreal Engine subsystem that relies on this setting variable is the Chaos physics system, specifically within the experimental Chaos module. This can be seen from the file path “Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClusteringAlgo.cpp”.

The value of this variable is set using an FAutoConsoleVariableRef, which allows it to be modified at runtime through console commands. It’s initialized with a default value of 4.

This variable interacts with another variable called MaxLevelsetDimension. Together, they define the range for the number of cells on a level set axis. It’s also used in conjunction with MinLevelsetSize, which determines the minimum size on the smallest axis to use a level set.

Developers must be aware that this variable affects the resolution and performance of level set collision detection in the Chaos physics system. A higher value will increase the precision of collision detection but may also increase computational costs.

Best practices when using this variable include:

  1. Balancing between precision and performance by adjusting the value.
  2. Considering the scale of your game objects when setting this value.
  3. Testing different values to find the optimal setting for your specific use case.

The associated variable MinLevelsetDimension is actually the internal representation of p.MinLevelsetDimension. It’s used directly in the code to clamp the number of cells in each dimension of the level set grid. This ensures that the level set resolution stays within the defined bounds, regardless of the object’s size or other factors.

When working with MinLevelsetDimension, developers should:

  1. Ensure it’s always less than or equal to MaxLevelsetDimension.
  2. Consider the impact on performance when increasing this value, especially for scenes with many complex collisions.
  3. Use it in conjunction with MinLevelsetSize to fine-tune the level set generation for different scales of objects in the game.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClusteringAlgo.cpp:19

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:


	int32 MinLevelsetDimension = 4;
	FAutoConsoleVariableRef CVarMinLevelsetDimension2(TEXT("p.MinLevelsetDimension"), MinLevelsetDimension, TEXT("The minimum number of cells on a single level set axis"));

	int32 MaxLevelsetDimension = 20;
	FAutoConsoleVariableRef CVarMaxLevelsetDimension2(TEXT("p.MaxLevelsetDimension"), MaxLevelsetDimension, TEXT("The maximum number of cells on a single level set axis"));

	FRealSingle MinLevelsetSize = 50.f;
	FAutoConsoleVariableRef CVarLevelSetResolution2(TEXT("p.MinLevelsetSize"), MinLevelsetSize, TEXT("The minimum size on the smallest axis to use a level set"));

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClusteringAlgo.cpp:18

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	FAutoConsoleVariableRef CVarUseLevelsetCollision2(TEXT("p.UseLevelsetCollision"), UseLevelsetCollision, TEXT("Whether unioned objects use levelsets"));

	int32 MinLevelsetDimension = 4;
	FAutoConsoleVariableRef CVarMinLevelsetDimension2(TEXT("p.MinLevelsetDimension"), MinLevelsetDimension, TEXT("The minimum number of cells on a single level set axis"));

	int32 MaxLevelsetDimension = 20;
	FAutoConsoleVariableRef CVarMaxLevelsetDimension2(TEXT("p.MaxLevelsetDimension"), MaxLevelsetDimension, TEXT("The maximum number of cells on a single level set axis"));

	FRealSingle MinLevelsetSize = 50.f;
	FAutoConsoleVariableRef CVarLevelSetResolution2(TEXT("p.MinLevelsetSize"), MinLevelsetSize, TEXT("The minimum size on the smallest axis to use a level set"));

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClusteringAlgo.cpp:388

Scope (from outer to inner):

file
namespace    Chaos
function     void UpdateGeometry

Source code excerpt:

					for (int i = 0; i < 3; ++i)
					{
						NumCells[i] = FMath::Clamp(NumCells[i], MinLevelsetDimension, MaxLevelsetDimension);
					}

					FErrorReporter ErrorReporter;
					TUniformGrid<FReal, 3> Grid(Bounds.Min(), Bounds.Max(), NumCells, LevelsetGhostCells);
					FLevelSet* LevelSet = new FLevelSet(ErrorReporter, Grid, UnionObject);