p.GeometryCollectionHardMissingUpdatesSnapThreshold
p.GeometryCollectionHardMissingUpdatesSnapThreshold
#Overview
name: p.GeometryCollectionHardMissingUpdatesSnapThreshold
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Determines how many missing updates before we trigger a hard snap
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.GeometryCollectionHardMissingUpdatesSnapThreshold is to determine the threshold for triggering a hard snap in Geometry Collection replication. It is used in the Geometry Collection component of Unreal Engine’s experimental physics system.
This setting variable is primarily used in the GeometryCollectionEngine module, specifically within the GeometryCollectionComponent. It’s part of the replication system for Geometry Collections, which are used for complex physics simulations and destruction effects.
The value of this variable is set using an FAutoConsoleVariableRef, which means it can be modified at runtime through console commands. The default value is set to 20.
This variable interacts closely with another variable named GeometryCollectionHardsnapThresholdMs. Together, they control when a hard snap should occur during replication.
Developers must be aware that this variable directly affects the frequency of hard snaps in networked Geometry Collection simulations. A lower value will cause more frequent hard snaps, which can improve accuracy but may increase network traffic and potentially cause visual discontinuities. A higher value will reduce the frequency of hard snaps but may lead to less accurate replication over time.
Best practices when using this variable include:
- Balancing it with GeometryCollectionHardsnapThresholdMs for optimal replication behavior.
- Testing different values in networked environments to find the best trade-off between accuracy and performance.
- Considering the specific requirements of the game or simulation when adjusting this value.
Regarding the associated variable GeometryCollectionHardMissingUpdatesSnapThreshold:
The purpose of GeometryCollectionHardMissingUpdatesSnapThreshold is the same as p.GeometryCollectionHardMissingUpdatesSnapThreshold. It’s the actual variable that stores the threshold value.
This variable is used directly in the ReplicationShouldHardSnap function to determine if a hard snap should occur based on the number of missing updates.
The value of this variable is set in the global scope of the GeometryCollectionComponent.cpp file and can be modified through the console variable system.
It interacts with the bGeometryCollectionRepUseClusterVelocityMatch variable, which determines whether to use physical velocity matching for cluster states.
Developers should be aware that this variable is the actual implementation of the threshold, while p.GeometryCollectionHardMissingUpdatesSnapThreshold is the console variable that allows runtime modification.
Best practices for this variable are the same as for p.GeometryCollectionHardMissingUpdatesSnapThreshold, as they represent the same concept.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/GeometryCollectionEngine/Private/GeometryCollection/GeometryCollectionComponent.cpp:2508
Scope: file
Source code excerpt:
int32 GeometryCollectionHardMissingUpdatesSnapThreshold = 20;
FAutoConsoleVariableRef CVarGeometryCollectionHardMissingUpdatesSnapThreshold(TEXT("p.GeometryCollectionHardMissingUpdatesSnapThreshold"), GeometryCollectionHardMissingUpdatesSnapThreshold,
TEXT("Determines how many missing updates before we trigger a hard snap"));
int32 GeometryCollectionHardsnapThresholdMs = 100; // 10 Hz
FAutoConsoleVariableRef CVarGeometryCollectionHardsnapThresholdMs(TEXT("p.GeometryCollectionHardsnapThresholdMs"), GeometryCollectionHardMissingUpdatesSnapThreshold,
TEXT("Determines how many ms since the last hardsnap to trigger a new one"));
#Associated Variable and Callsites
This variable is associated with another variable named GeometryCollectionHardMissingUpdatesSnapThreshold
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/GeometryCollectionEngine/Private/GeometryCollection/GeometryCollectionComponent.cpp:2504
Scope: file
Source code excerpt:
bool bGeometryCollectionRepUseClusterVelocityMatch = true;
FAutoConsoleVariableRef CVarGeometryCollectionRepUseClusterVelocityMatch(TEXT("p.bGeometryCollectionRepUseClusterVelocityMatch"), bGeometryCollectionRepUseClusterVelocityMatch,
TEXT("Use physical velocity to match cluster states"));
int32 GeometryCollectionHardMissingUpdatesSnapThreshold = 20;
FAutoConsoleVariableRef CVarGeometryCollectionHardMissingUpdatesSnapThreshold(TEXT("p.GeometryCollectionHardMissingUpdatesSnapThreshold"), GeometryCollectionHardMissingUpdatesSnapThreshold,
TEXT("Determines how many missing updates before we trigger a hard snap"));
int32 GeometryCollectionHardsnapThresholdMs = 100; // 10 Hz
FAutoConsoleVariableRef CVarGeometryCollectionHardsnapThresholdMs(TEXT("p.GeometryCollectionHardsnapThresholdMs"), GeometryCollectionHardMissingUpdatesSnapThreshold,
TEXT("Determines how many ms since the last hardsnap to trigger a new one"));
void UGeometryCollectionComponent::ProcessRepData()
{
bGeometryCollectionRepUseClusterVelocityMatch = false;
ProcessRepData(0.f, 0.f);
}
namespace
{
bool ReplicationShouldHardSnap(int32 RepDataVersion, int32 VersionProcessed, bool bReplicateMovement, double& LastHardsnapTimeInMs)
#Loc: <Workspace>/Engine/Source/Runtime/Experimental/GeometryCollectionEngine/Private/GeometryCollection/GeometryCollectionComponent.cpp:2536
Scope (from outer to inner):
file
namespace anonymous
function bool ReplicationShouldHardSnap
Source code excerpt:
}
else if (VersionProcessed < RepDataVersion)
{
//TODO: this will not really work if a fracture happens and then immediately goes to sleep without updating client enough times
//A time method would work better here, but is limited to async mode. Maybe we can support both
bHardSnap = (RepDataVersion - VersionProcessed) > GeometryCollectionHardMissingUpdatesSnapThreshold;
if (!bGeometryCollectionRepUseClusterVelocityMatch)
{
// When not doing velocity match for clusters, instead we do periodic hard snapping
bHardSnap |= (CurrentTimeInMs - LastHardsnapTimeInMs) > GeometryCollectionHardsnapThresholdMs;
}
}
else if (VersionProcessed > RepDataVersion)
{
//rollover so just treat as hard snap - this case is extremely rare and a one off
bHardSnap = true;