p.MinCleanedPointsBeforeRemovingInternals
p.MinCleanedPointsBeforeRemovingInternals
#Overview
name: p.MinCleanedPointsBeforeRemovingInternals
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If we only have this many clean points, don\'t bother removing internal points as the object is likely very small
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.MinCleanedPointsBeforeRemovingInternals is to control the threshold for removing internal points in the Chaos physics system, specifically in the rigid clustering algorithm. This setting is used to determine when it’s appropriate to remove internal points from a collision object, based on the number of clean points remaining.
This setting variable is primarily used in the Chaos physics system, which is an experimental physics engine in Unreal Engine 5. It’s part of the rigid clustering algorithm, which is likely used for optimizing collision detection and physics simulations for complex objects.
The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through the console or configuration files. The default value is set to 10.
The associated variable MinCleanedPointsBeforeRemovingInternals directly interacts with p.MinCleanedPointsBeforeRemovingInternals. They share the same value and are used interchangeably in the code.
Developers must be aware that this variable affects the performance and accuracy of collision detection for small objects. If the number of clean points is less than or equal to this threshold, the system won’t remove internal points, assuming the object is very small.
Best practices when using this variable include:
- Carefully adjusting the value based on the scale and complexity of objects in your game.
- Testing different values to find the optimal balance between performance and collision accuracy.
- Monitoring performance metrics when changing this value, as it can impact physics simulation performance.
Regarding the associated variable MinCleanedPointsBeforeRemovingInternals:
This variable is the actual integer value used in the code logic. It’s initialized with the same value as p.MinCleanedPointsBeforeRemovingInternals (10 by default) and is used in the UpdateGeometry function to determine whether to remove internal points from the collision geometry.
The purpose of this variable is the same as p.MinCleanedPointsBeforeRemovingInternals, but it’s the actual variable used in the logic rather than the console variable reference. It’s used to prevent removing internal points when the object has very few clean points, which could happen for very small objects.
Developers should be aware that modifying p.MinCleanedPointsBeforeRemovingInternals through the console or configuration will directly affect this variable’s value. When working with the Chaos physics system, particularly with small objects or complex geometries, developers may need to fine-tune this value to achieve the desired balance between performance and collision accuracy.
#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:31
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
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(""));
DECLARE_CYCLE_STAT(TEXT("TPBDRigidClustering<>::UpdateClusterMassProperties()"), STAT_UpdateClusterMassProperties, STATGROUP_Chaos);
void UpdateClusterMassProperties(
#Associated Variable and Callsites
This variable is associated with another variable named MinCleanedPointsBeforeRemovingInternals
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClusteringAlgo.cpp:30
Scope (from outer to inner):
file
namespace Chaos
Source code excerpt:
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(""));
DECLARE_CYCLE_STAT(TEXT("TPBDRigidClustering<>::UpdateClusterMassProperties()"), STAT_UpdateClusterMassProperties, STATGROUP_Chaos);
void UpdateClusterMassProperties(
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/PBDRigidClusteringAlgo.cpp:400
Scope (from outer to inner):
file
namespace Chaos
function void UpdateGeometry
Source code excerpt:
for (int32 Idx = CleanedPoints.Num() - 1; Idx >= 0; --Idx)
{
if (CleanedPoints.Num() > MinCleanedPointsBeforeRemovingInternals) //todo(ocohen): this whole thing should really be refactored
{
const FVec3& CleanedCollision = CleanedPoints[Idx];
if (LevelSet->SignedDistance(CleanedCollision) < -MinDepthToSurface)
{
CleanedPoints.RemoveAtSwap(Idx);
}