demo.CullDistanceOverride
demo.CullDistanceOverride
#Overview
name: demo.CullDistanceOverride
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If > 0, will represent distance from any viewer where actors will stop being recorded.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of demo.CullDistanceOverride is to control the distance at which actors stop being recorded in the demo system of Unreal Engine 5. This setting is primarily used for optimizing demo recording and playback.
-
This setting variable is part of the demo system in Unreal Engine, which is responsible for recording and replaying gameplay sessions.
-
The Unreal Engine subsystem that relies on this setting variable is the DemoNetDriver, which is part of the Engine module. This can be seen from the file path where the variable is defined:
Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp
. -
The value of this variable is set as a console variable (CVar) with a default value of 0.0f. It can be modified at runtime through console commands or programmatically.
-
This variable interacts with other demo-related variables, such as CVarDemoUseNetRelevancy and CVarDemoRecordHzWhenNotRelevant, which together control the behavior of actor culling and recording frequency in demos.
-
Developers must be aware that this variable only takes effect when its value is greater than 0.0. When set, it determines the distance from any viewer beyond which actors will not be recorded in the demo.
-
Best practices for using this variable include:
- Use it in conjunction with CVarDemoUseNetRelevancy to optimize demo recording performance.
- Adjust the value based on the specific needs of your game to balance between recording fidelity and performance.
- Be cautious when setting very low values, as it might result in important actors not being recorded.
Regarding the associated variable CVarDemoCullDistanceOverride:
The purpose of CVarDemoCullDistanceOverride is the same as demo.CullDistanceOverride. It’s the internal representation of the console variable within the C++ code.
-
This variable is used directly in the DemoNetDriver’s TickDemoRecordFrame function to determine the actual cull distance for actors during demo recording.
-
The value is retrieved using GetValueOnAnyThread(), which suggests it can be safely accessed from multiple threads.
-
It’s used to calculate CullDistanceOverrideSq, which is likely used for efficient distance comparisons (using squared distances to avoid costly square root operations).
-
Developers should note that changes to this variable will take effect in real-time during demo recording.
-
Best practices include using this variable for fine-tuning demo recording performance, especially in large or complex game worlds where culling distant actors can significantly improve performance.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:62
Scope: file
Source code excerpt:
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."));
static TAutoConsoleVariable<int32> CVarDemoJumpToEndOfLiveReplay(TEXT("demo.JumpToEndOfLiveReplay"), 1, TEXT("If true, fast forward to a few seconds before the end when starting playback, if the replay is still being recorded."));
#Associated Variable and Callsites
This variable is associated with another variable named CVarDemoCullDistanceOverride
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:62
Scope: file
Source code excerpt:
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."));
static TAutoConsoleVariable<int32> CVarDemoJumpToEndOfLiveReplay(TEXT("demo.JumpToEndOfLiveReplay"), 1, TEXT("If true, fast forward to a few seconds before the end when starting playback, if the replay is still being recorded."));
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:1960
Scope (from outer to inner):
file
function void UDemoNetDriver::TickDemoRecordFrame
Source code excerpt:
}
const float CullDistanceOverride = CVarDemoCullDistanceOverride.GetValueOnAnyThread();
const float CullDistanceOverrideSq = CullDistanceOverride > 0.0f ? FMath::Square(CullDistanceOverride) : 0.0f;
const float RecordHzWhenNotRelevant = CVarDemoRecordHzWhenNotRelevant.GetValueOnAnyThread();
const float UpdateDelayWhenNotRelevant = RecordHzWhenNotRelevant > 0.0f ? 1.0f / RecordHzWhenNotRelevant : 0.5f;
TArray<AActor*, TInlineAllocator<128>> ActorsToRemove;