p.GeometryCollectionHardsnapThresholdMs
p.GeometryCollectionHardsnapThresholdMs
#Overview
name: p.GeometryCollectionHardsnapThresholdMs
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Determines how many ms since the last hardsnap to trigger a new one
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of p.GeometryCollectionHardsnapThresholdMs is to determine the time interval in milliseconds between hard snaps for Geometry Collection components in Unreal Engine 5. It is primarily used in the replication and network synchronization of Geometry Collection components.
This setting variable is relied upon by the Experimental GeometryCollectionEngine module, specifically within the GeometryCollectionComponent class. It is part of the replication system for Geometry Collections, which are used for destructible and fracturing effects in the engine.
The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through console commands. It is initialized with a default value of 100 milliseconds (10 Hz).
This variable interacts closely with GeometryCollectionHardMissingUpdatesSnapThreshold. In fact, there appears to be a mistake in the code where GeometryCollectionHardMissingUpdatesSnapThreshold is used instead of GeometryCollectionHardsnapThresholdMs when setting up the console variable reference.
Developers must be aware that this variable is used to control the frequency of hard snaps when not using cluster velocity matching for replication. A hard snap is a forced synchronization of the Geometry Collection’s state, which can be more visually noticeable but ensures accuracy.
Best practices when using this variable include:
- Adjusting it based on the specific needs of your project, balancing between network performance and visual smoothness.
- Using it in conjunction with bGeometryCollectionRepUseClusterVelocityMatch to fine-tune replication behavior.
- Being cautious of setting it too low, which could lead to frequent hard snaps and potentially choppy visuals.
Regarding the associated variable GeometryCollectionHardMissingUpdatesSnapThreshold:
The purpose of GeometryCollectionHardMissingUpdatesSnapThreshold is to determine how many missing updates should trigger a hard snap in the Geometry Collection replication system.
This variable is also used in the Experimental GeometryCollectionEngine module, specifically for replication logic in the GeometryCollectionComponent.
Its value is set using an FAutoConsoleVariableRef, allowing for runtime adjustment via console commands. The default value is 20 missing updates.
This threshold works in tandem with p.GeometryCollectionHardsnapThresholdMs, providing an alternative condition for triggering hard snaps based on the number of missing updates rather than elapsed time.
Developers should be aware that this variable directly impacts the frequency of hard snaps when there are gaps in replication data. A lower value will result in more frequent hard snaps, potentially improving accuracy at the cost of smoothness.
Best practices for using this variable include:
- Balancing it with p.GeometryCollectionHardsnapThresholdMs to achieve optimal replication behavior.
- Adjusting based on network conditions and the specific requirements of your game.
- Monitoring its effect on both network performance and visual quality during gameplay.
#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:2512
Scope: file
Source code excerpt:
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);
#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;