p.MinLevelsetSize
p.MinLevelsetSize
#Overview
name: p.MinLevelsetSize
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
The minimum size on the smallest axis to use a level set
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.MinLevelsetSize is to define the minimum size on the smallest axis for using a level set in the Chaos physics system of Unreal Engine 5. This setting is primarily used in the physics simulation, specifically for rigid body clustering algorithms.
The Unreal Engine subsystem that relies on this setting variable is the Experimental Chaos physics module. This can be seen from the file path where the variable is defined: “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. The initial value is set to 50.0f.
This variable interacts with other variables in the same context, such as MaxLevelsetDimension and LevelsetGhostCells. It’s used in conjunction with these variables to determine the appropriate level set configuration for physics simulations.
Developers must be aware that this variable affects the precision and performance of physics simulations, particularly for rigid body clustering. Setting it too low might result in unnecessary computational overhead for small objects, while setting it too high might reduce the accuracy of simulations for smaller objects.
Best practices when using this variable include:
- Adjusting it based on the scale of your game world and objects.
- Testing different values to find the right balance between performance and accuracy.
- Considering the impact on both large and small objects in your scene.
Regarding the associated variable MinLevelsetSize:
The purpose of MinLevelsetSize is the same as p.MinLevelsetSize, as they share the same value. It’s the actual variable used in the code logic, while p.MinLevelsetSize is the console variable that allows runtime modification.
This variable is used directly in the UpdateGeometry function to determine if an object is large enough to use a level set representation. If the smallest extent of an object’s bounding box is greater than or equal to MinLevelsetSize, a level set is used for that object.
Developers should be aware that changing p.MinLevelsetSize will directly affect MinLevelsetSize and thus the behavior of the physics simulation. They should carefully consider the size range of objects in their game when adjusting this value to ensure optimal performance and accuracy across all scales of objects.
#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:25
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
FRealSingle MinLevelsetSize = 50.f;
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"));
#Associated Variable and Callsites
This variable is associated with another variable named MinLevelsetSize
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClusteringAlgo.cpp:24
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
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"));
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"));
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClusteringAlgo.cpp:383
Scope (from outer to inner):
file
namespace Chaos
function void UpdateGeometry
Source code excerpt:
FAABB3 Bounds = UnionObject.BoundingBox();
const FVec3 BoundsExtents = Bounds.Extents();
if (BoundsExtents.Min() >= MinLevelsetSize) //make sure the object is not too small
{
TVec3<int32> NumCells = Bounds.Extents() / MinLevelsetSize;
for (int i = 0; i < 3; ++i)
{
NumCells[i] = FMath::Clamp(NumCells[i], MinLevelsetDimension, MaxLevelsetDimension);
}
FErrorReporter ErrorReporter;