p.LevelsetGhostCells

p.LevelsetGhostCells

#Overview

name: p.LevelsetGhostCells

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.LevelsetGhostCells is to control the number of ghost cells added to the level set grid in the Chaos physics system of Unreal Engine 5. It is primarily used for the physics simulation, specifically in the rigid body clustering algorithm.

This setting variable is utilized in the Chaos module, which is part of Unreal Engine’s experimental physics system. It’s specifically used in the PBDRigidClusteringAlgo.cpp file, indicating its relevance to the Particle-Based Dynamics (PBD) rigid clustering algorithm.

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 1.

The associated variable LevelsetGhostCells directly interacts with p.LevelsetGhostCells. They share the same value, with LevelsetGhostCells being the actual variable used in the code, while p.LevelsetGhostCells is the console variable name.

Developers should be aware that this variable affects the size of the level set grid used in physics calculations. Increasing this value will expand the grid by adding more ghost cells, which can potentially improve the accuracy of physics simulations at the cost of increased memory usage and computation time.

Best practices when using this variable include:

  1. Only modify it if you understand the implications on physics simulation accuracy and performance.
  2. Monitor performance metrics when adjusting this value, as it can impact simulation speed.
  3. Consider the trade-off between simulation accuracy and performance when changing this value.

Regarding the associated variable LevelsetGhostCells:

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:


	int32 LevelsetGhostCells = 1;
	FAutoConsoleVariableRef CVarLevelsetGhostCells2(TEXT("p.LevelsetGhostCells"), LevelsetGhostCells, TEXT("Increase the level set grid by this many ghost cells"));

	int32 MinCleanedPointsBeforeRemovingInternals = 10;
	FAutoConsoleVariableRef CVarMinCleanedPointsBeforeRemovingInternals2(TEXT("p.MinCleanedPointsBeforeRemovingInternals"), MinCleanedPointsBeforeRemovingInternals, TEXT("If we only have this many clean points, don't bother removing internal points as the object is likely very small"));

	FRealSingle ClusterSnapDistance = 1.f;
	FAutoConsoleVariableRef CVarClusterSnapDistance2(TEXT("p.ClusterSnapDistance"), ClusterSnapDistance, TEXT(""));

#Associated Variable and Callsites

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

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

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

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

	int32 LevelsetGhostCells = 1;
	FAutoConsoleVariableRef CVarLevelsetGhostCells2(TEXT("p.LevelsetGhostCells"), LevelsetGhostCells, TEXT("Increase the level set grid by this many ghost cells"));

	int32 MinCleanedPointsBeforeRemovingInternals = 10;
	FAutoConsoleVariableRef CVarMinCleanedPointsBeforeRemovingInternals2(TEXT("p.MinCleanedPointsBeforeRemovingInternals"), MinCleanedPointsBeforeRemovingInternals, TEXT("If we only have this many clean points, don't bother removing internal points as the object is likely very small"));

	FRealSingle ClusterSnapDistance = 1.f;
	FAutoConsoleVariableRef CVarClusterSnapDistance2(TEXT("p.ClusterSnapDistance"), ClusterSnapDistance, TEXT(""));

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

Scope (from outer to inner):

file
namespace    Chaos
function     void UpdateGeometry

Source code excerpt:


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

					if (!Parameters.CollisionParticles)
					{
						const FReal MinDepthToSurface = Grid.Dx().Max();
						for (int32 Idx = CleanedPoints.Num() - 1; Idx >= 0; --Idx)