demo.UseNetRelevancy
demo.UseNetRelevancy
#Overview
name: demo.UseNetRelevancy
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If 1, will enable relevancy checks and distance culling, using all connected clients as reference.
It is referenced in 6
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of demo.UseNetRelevancy is to enable relevancy checks and distance culling for demo recordings in Unreal Engine 5. This setting is primarily used in the networking and demo recording systems.
The Unreal Engine subsystem that relies on this setting variable is the demo recording system, specifically within the DemoNetDriver module. This can be seen from the file locations where the variable is referenced, such as DemoNetDriver.cpp and ReplayHelper.cpp.
The value of this variable is set as a console variable (CVar) with an initial value of 0. It can be changed at runtime through console commands or programmatically.
The associated variable CVarDemoUseNetRelevancy interacts directly with demo.UseNetRelevancy, as they share the same value and purpose.
Developers must be aware that enabling this variable (setting it to 1) will impact demo recording performance and behavior. It will cause the system to perform relevancy checks and distance culling based on all connected clients, which can affect what gets recorded in the demo.
Best practices when using this variable include:
- Only enable it when network relevancy is crucial for the demo recording.
- Be aware of the performance implications, especially with a large number of connected clients.
- Test thoroughly with it both enabled and disabled to understand its impact on your specific use case.
Regarding the associated variable CVarDemoUseNetRelevancy:
The purpose of CVarDemoUseNetRelevancy is identical to demo.UseNetRelevancy, as they are essentially the same variable accessed through different means.
It is used in the same subsystems (demo recording and networking) as demo.UseNetRelevancy.
The value is set through the TAutoConsoleVariable system, allowing for runtime changes.
It interacts directly with demo.UseNetRelevancy, and its value is checked in various parts of the demo recording system to determine whether to perform relevancy checks and distance culling.
Developers should be aware that this variable is used to control the behavior of the demo recording system in terms of network relevancy.
Best practices for using CVarDemoUseNetRelevancy are the same as for demo.UseNetRelevancy, focusing on performance considerations and thorough testing when enabling or disabling the feature.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:61
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarDemoClientRecordAsyncEndOfFrame( TEXT( "demo.ClientRecordAsyncEndOfFrame" ), 0, TEXT( "If true, TickFlush will be called on a thread in parallel with Slate." ) );
static TAutoConsoleVariable<int32> CVarForceDisableAsyncPackageMapLoading( TEXT( "demo.ForceDisableAsyncPackageMapLoading" ), 0, TEXT( "If true, async package map loading of network assets will be disabled." ) );
TAutoConsoleVariable<int32> CVarDemoUseNetRelevancy( TEXT( "demo.UseNetRelevancy" ), 0, TEXT( "If 1, will enable relevancy checks and distance culling, using all connected clients as reference." ) );
static TAutoConsoleVariable<float> CVarDemoCullDistanceOverride( TEXT( "demo.CullDistanceOverride" ), 0.0f, TEXT( "If > 0, will represent distance from any viewer where actors will stop being recorded." ) );
static TAutoConsoleVariable<float> CVarDemoRecordHzWhenNotRelevant( TEXT( "demo.RecordHzWhenNotRelevant" ), 2.0f, TEXT( "Record at this frequency when actor is not relevant." ) );
static TAutoConsoleVariable<int32> CVarLoopDemo(TEXT("demo.Loop"), 0, TEXT("<1> : play replay from beginning once it reaches the end / <0> : stop replay at the end"));
static TAutoConsoleVariable<int32> CVarDemoFastForwardIgnoreRPCs( TEXT( "demo.FastForwardIgnoreRPCs" ), 1, TEXT( "If true, RPCs will be discarded during playback fast forward." ) );
static TAutoConsoleVariable<int32> CVarDemoLateActorDormancyCheck(TEXT("demo.LateActorDormancyCheck"), 1, TEXT("If true, check if an actor should become dormant as late as possible- when serializing it to the demo archive."));
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:1681
Scope: file
Source code excerpt:
/**
* FReplayViewer
* Used when demo.UseNetRelevancy enabled
* Tracks all of the possible viewers of a replay that we use to determine relevancy
*/
class FReplayViewer
{
public:
FReplayViewer(const UNetConnection* Connection) :
Viewer(Connection->PlayerController ? Connection->PlayerController : Connection->OwningActor),
ViewTarget(Connection->PlayerController ? Connection->PlayerController->GetViewTarget() : ToRawPtr(Connection->OwningActor))
{
Location = ViewTarget ? ViewTarget->GetActorLocation() : FVector::ZeroVector;
#Associated Variable and Callsites
This variable is associated with another variable named CVarDemoUseNetRelevancy
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:61
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarDemoClientRecordAsyncEndOfFrame( TEXT( "demo.ClientRecordAsyncEndOfFrame" ), 0, TEXT( "If true, TickFlush will be called on a thread in parallel with Slate." ) );
static TAutoConsoleVariable<int32> CVarForceDisableAsyncPackageMapLoading( TEXT( "demo.ForceDisableAsyncPackageMapLoading" ), 0, TEXT( "If true, async package map loading of network assets will be disabled." ) );
TAutoConsoleVariable<int32> CVarDemoUseNetRelevancy( TEXT( "demo.UseNetRelevancy" ), 0, TEXT( "If 1, will enable relevancy checks and distance culling, using all connected clients as reference." ) );
static TAutoConsoleVariable<float> CVarDemoCullDistanceOverride( TEXT( "demo.CullDistanceOverride" ), 0.0f, TEXT( "If > 0, will represent distance from any viewer where actors will stop being recorded." ) );
static TAutoConsoleVariable<float> CVarDemoRecordHzWhenNotRelevant( TEXT( "demo.RecordHzWhenNotRelevant" ), 2.0f, TEXT( "Record at this frequency when actor is not relevant." ) );
static TAutoConsoleVariable<int32> CVarLoopDemo(TEXT("demo.Loop"), 0, TEXT("<1> : play replay from beginning once it reaches the end / <0> : stop replay at the end"));
static TAutoConsoleVariable<int32> CVarDemoFastForwardIgnoreRPCs( TEXT( "demo.FastForwardIgnoreRPCs" ), 1, TEXT( "If true, RPCs will be discarded during playback fast forward." ) );
static TAutoConsoleVariable<int32> CVarDemoLateActorDormancyCheck(TEXT("demo.LateActorDormancyCheck"), 1, TEXT("If true, check if an actor should become dormant as late as possible- when serializing it to the demo archive."));
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:1945
Scope (from outer to inner):
file
function void UDemoNetDriver::TickDemoRecordFrame
Source code excerpt:
TArray< FReplayViewer, TInlineAllocator<16> > ReplayViewers;
const bool bUseNetRelevancy = CVarDemoUseNetRelevancy.GetValueOnAnyThread() > 0 && World->NetDriver != nullptr && World->NetDriver->IsServer();
// If we're using relevancy, consider all connections as possible viewing sources
if (bUseNetRelevancy)
{
for (UNetConnection* Connection : World->NetDriver->ClientConnections)
{
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ReplayHelper.cpp:26
Scope: file
Source code excerpt:
extern TAutoConsoleVariable<float> CVarCheckpointUploadDelayInSeconds;
extern TAutoConsoleVariable<float> CVarCheckpointSaveMaxMSPerFrameOverride;
extern TAutoConsoleVariable<int32> CVarDemoUseNetRelevancy;
extern TAutoConsoleVariable<int32> CVarDemoClientRecordAsyncEndOfFrame;
extern TAutoConsoleVariable<float> CVarDemoRecordHz;
extern TAutoConsoleVariable<float> CVarDemoMinRecordHz;
CSV_DECLARE_CATEGORY_EXTERN(Demo);
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/ReplayHelper.cpp:272
Scope (from outer to inner):
file
function void FReplayHelper::WriteNetworkDemoHeader
Source code excerpt:
}
if (CVarDemoUseNetRelevancy.GetValueOnAnyThread() > 0)
{
DemoHeader.HeaderFlags |= EReplayHeaderFlags::NetRelevancyEnabled;
}
DemoHeader.Guid = FGuid::NewGuid();