p.gc.GlobalMaxSimulatedLevel
p.gc.GlobalMaxSimulatedLevel
#Overview
name: p.gc.GlobalMaxSimulatedLevel
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Allow to set the Global Maximum Simulated Level for Geoemtry Collection. The min between the MaxSimulatedLevel and the GlobalMaxSimulatedLevel will be used.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.gc.GlobalMaxSimulatedLevel is to set a global limit on the maximum simulated level for Geometry Collections in Unreal Engine’s Chaos physics system. This setting is used to control the level of detail in physics simulations for geometry collections, which are hierarchical structures used for destructible objects.
This setting variable is primarily used in the Chaos physics system, which is part of Unreal Engine’s experimental physics module. It’s specifically utilized in the GeometryCollectionPhysicsProxy class, which handles the physics representation of geometry collections.
The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through console commands. The default value is set to 100.
The GlobalMaxSimulatedLevel variable interacts closely with other variables such as Parameters.MaxClusterLevel and Parameters.MaxSimulatedLevel. In the code, the minimum value among these three is used to determine the actual maximum simulated level.
Developers must be aware that this variable acts as a global cap on the simulation level. Even if individual geometry collections have higher MaxSimulatedLevel values, they will be limited by this global setting.
Best practices when using this variable include:
- Use it to globally optimize performance by limiting the maximum simulation detail across all geometry collections.
- Adjust it carefully, as it affects all geometry collections in the scene.
- Consider the trade-off between simulation accuracy and performance when setting this value.
Regarding the associated variable GlobalMaxSimulatedLevel:
The purpose of GlobalMaxSimulatedLevel is the same as p.gc.GlobalMaxSimulatedLevel. It’s the actual integer variable that stores the value, while p.gc.GlobalMaxSimulatedLevel is the console variable that exposes it for runtime adjustment.
This variable is used in the Chaos physics system, specifically in the GeometryCollectionPhysicsProxy class. It’s used in calculations for damage thresholds and effective particles in geometry collections.
The value is set initially to 100 and can be modified through the console variable p.gc.GlobalMaxSimulatedLevel.
It interacts with other variables like Parameters.MaxClusterLevel and Parameters.MaxSimulatedLevel, often being used in FMath::Min() calls to determine the effective maximum simulated level.
Developers should be aware that this variable directly affects the behavior of geometry collections in physics simulations. Changes to this value will impact all geometry collections in the scene.
Best practices include carefully considering the performance implications when adjusting this value and testing thoroughly to ensure desired behavior across different scenarios 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/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:1772
Scope: file
Source code excerpt:
int32 GlobalMaxSimulatedLevel = 100;
FAutoConsoleVariableRef CVarGlobalMaxSimulatedLevel(TEXT("p.gc.GlobalMaxSimulatedLevel"), GlobalMaxSimulatedLevel, TEXT("Allow to set the Global Maximum Simulated Level for Geoemtry Collection. The min between the MaxSimulatedLevel and the GlobalMaxSimulatedLevel will be used. "));
DECLARE_CYCLE_STAT(TEXT("FGeometryCollectionPhysicsProxy::BuildClusters"), STAT_BuildClusters, STATGROUP_Chaos);
DECLARE_CYCLE_STAT(TEXT("FGeometryCollectionPhysicsProxy::BuildClusters:GlobalMatrices"), STAT_BuildClustersGlobalMatrices, STATGROUP_Chaos);
float FGeometryCollectionPhysicsProxy::ComputeMaterialBasedDamageThreshold_Internal(int32 TransformIndex) const
#Associated Variable and Callsites
This variable is associated with another variable named GlobalMaxSimulatedLevel
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:1771
Scope: file
Source code excerpt:
FAutoConsoleVariableRef CVarReportNoLevelsetCluster(TEXT("p.gc.ReportNoLevelsetCluster"), ReportNoLevelsetCluster, TEXT("Report any cluster objects without levelsets"));
int32 GlobalMaxSimulatedLevel = 100;
FAutoConsoleVariableRef CVarGlobalMaxSimulatedLevel(TEXT("p.gc.GlobalMaxSimulatedLevel"), GlobalMaxSimulatedLevel, TEXT("Allow to set the Global Maximum Simulated Level for Geoemtry Collection. The min between the MaxSimulatedLevel and the GlobalMaxSimulatedLevel will be used. "));
DECLARE_CYCLE_STAT(TEXT("FGeometryCollectionPhysicsProxy::BuildClusters"), STAT_BuildClusters, STATGROUP_Chaos);
DECLARE_CYCLE_STAT(TEXT("FGeometryCollectionPhysicsProxy::BuildClusters:GlobalMatrices"), STAT_BuildClustersGlobalMatrices, STATGROUP_Chaos);
float FGeometryCollectionPhysicsProxy::ComputeMaterialBasedDamageThreshold_Internal(int32 TransformIndex) const
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:1846
Scope (from outer to inner):
file
function float FGeometryCollectionPhysicsProxy::ComputeUserDefinedDamageThreshold_Internal
Source code excerpt:
const int32 LevelOffset = Parameters.bUsePerClusterOnlyDamageThreshold ? 0 : -1;
const int32 Level = FMath::Clamp(CalculateHierarchyLevel(PhysicsThreadCollection, TransformIndex) + LevelOffset, 0, INT_MAX);
if (Level >= FMath::Min(Parameters.MaxClusterLevel, FMath::Min(GlobalMaxSimulatedLevel, Parameters.MaxSimulatedLevel)))
{
DamageThreshold = TNumericLimits<float>::Max();
}
else if (Parameters.DamageModel == EDamageModelTypeEnum::Chaos_Damage_Model_UserDefined_Damage_Threshold)
{
const int32 ParticleIndex = FromTransformToParticleIndex[TransformIndex];
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/PhysicsProxy/GeometryCollectionPhysicsProxy.cpp:2996
Scope (from outer to inner):
file
function int32 FGeometryCollectionPhysicsProxy::CalculateEffectiveParticles
Source code excerpt:
int32 NumEffectiveParticlesFound = 0;
EffectiveParticles.Init(false, NumTransform);
const int32 MaxSimulatedLevel = FMath::Min(GlobalMaxSimulatedLevel, InMaxSimulatedLevel);
const TManagedArray<Chaos::FImplicitObjectPtr>& Implicits = DynamicCollection.GetAttribute<Chaos::FImplicitObjectPtr>(FGeometryDynamicCollection::ImplicitsAttribute, FTransformCollection::TransformGroup);
TManagedArrayAccessor<int32> Levels = DynamicCollection.GetInitialLevels();
for (int32 TransformIndex = 0; TransformIndex < NumTransform; ++TransformIndex)
{
const int32 Level = Levels[TransformIndex];