p.UseLevelsetCollision
p.UseLevelsetCollision
#Overview
name: p.UseLevelsetCollision
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether unioned objects use levelsets
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.UseLevelsetCollision is to control whether unioned objects use levelsets for collision detection in the Chaos physics system of Unreal Engine 5. This setting variable is primarily used in the physics simulation, specifically for handling collisions in clustered rigid body dynamics.
The Unreal Engine subsystem that relies on this setting variable is the Chaos physics system, which is part of the Experimental 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 creates a console variable that can be modified at runtime. It is initialized to 0 (false) by default.
The associated variable UseLevelsetCollision interacts directly with p.UseLevelsetCollision. They share the same value and are used interchangeably in the code.
Developers must be aware that this variable affects the collision detection method for unioned objects in clustered rigid body simulations. When enabled (set to 1 or true), it uses levelset-based collision detection for these objects.
Best practices when using this variable include:
- Consider the performance implications of enabling levelset collision, as it may be more computationally expensive.
- Test the physics behavior with both settings (enabled and disabled) to determine which provides better results for your specific use case.
- Be aware that enabling this feature might change the collision behavior of clustered objects in your game or simulation.
Regarding the associated variable UseLevelsetCollision:
- It is an int32 variable that acts as a boolean flag (0 for false, non-zero for true).
- It is used directly in conditional statements to determine whether to use levelset collision for unioned objects.
- The variable is checked in the UpdateGeometry function, which is part of the clustering algorithm for rigid bodies.
- When UseLevelsetCollision is true, the code creates a FImplicitObjectUnionClustered object for handling the collision of multiple clustered objects.
- When UseLevelsetCollision is false, the code takes a simpler approach, either using a single object’s geometry or creating a TImplicitObjectUnion without levelset calculations.
Developers should consider the trade-offs between accuracy and performance when deciding whether to enable levelset collision for their clustered rigid body 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/PBDRigidClusteringAlgo.cpp:16
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
int32 UseLevelsetCollision = 0;
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"));
#Associated Variable and Callsites
This variable is associated with another variable named UseLevelsetCollision
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClusteringAlgo.cpp:15
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
//
int32 UseLevelsetCollision = 0;
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"));
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClusteringAlgo.cpp:376
Scope (from outer to inner):
file
namespace Chaos
function void UpdateGeometry
Source code excerpt:
else
{
if (UseLevelsetCollision)
{
ensureMsgf(false, TEXT("Checking usage with no proxy and multiple ojects with levelsets"));
FImplicitObjectUnionClustered UnionObject(MoveTemp(Objects));
FAABB3 Bounds = UnionObject.BoundingBox();
const FVec3 BoundsExtents = Bounds.Extents();
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClusteringAlgo.cpp:418
Scope (from outer to inner):
file
namespace Chaos
function void UpdateGeometry
Source code excerpt:
}
}
else // !UseLevelsetCollision
{
if (Objects.Num() == 1)
{
Parent->SetGeometry(MoveTemp(Objects[0]));
}
else