demo.DestructionInfoPriority

demo.DestructionInfoPriority

#Overview

name: demo.DestructionInfoPriority

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of demo.DestructionInfoPriority is to assign a replay net priority to destruction infos during recording in Unreal Engine’s demo (replay) system.

This setting variable is primarily used in the demo recording subsystem of Unreal Engine, specifically within the DemoNetDriver module. It’s part of the networking and replay functionality.

The value of this variable is set as a console variable, which means it can be adjusted at runtime or set in configuration files. In the provided code, it’s initialized with the maximum possible integer value (MAX_int32).

The associated variable CVarDemoDestructionInfoPriority directly interacts with demo.DestructionInfoPriority. They share the same value and purpose.

Developers must be aware that this variable significantly impacts the priority of destruction information during demo recording. Setting it to the maximum integer value ensures that destruction infos are given the highest priority, which could affect performance and network bandwidth usage if there are many objects being destroyed.

Best practices when using this variable include:

  1. Carefully consider the impact on network performance before adjusting this value.
  2. Monitor the demo recording process to ensure that giving such high priority to destruction infos doesn’t negatively impact other important network traffic.
  3. Consider lowering the priority if destruction infos are overwhelming other important game state updates in the replay.

Regarding the associated variable CVarDemoDestructionInfoPriority:

The purpose of CVarDemoDestructionInfoPriority is identical to demo.DestructionInfoPriority. It’s used to store and access the priority value for destruction infos during demo recording.

This variable is used directly in the UDemoNetDriver::TickDemoRecordFrame function to set the priority of destroyed actors that the client may not have a channel for. This suggests it’s crucial for ensuring that object destruction is accurately captured in replays, even for objects that might not be actively tracked by the client.

The value of CVarDemoDestructionInfoPriority is set through the console variable system and can be accessed using the GetValueOnAnyThread() method, allowing for thread-safe access to its value.

Developers should be aware that changes to this variable will directly affect how destruction information is prioritized in the demo recording process. High values ensure destruction info is sent promptly, but could potentially overshadow other important game state updates.

Best practices include:

  1. Regularly reviewing and potentially adjusting this value based on the specific needs of your game and its networking requirements.
  2. Balancing this priority against other important network events to ensure a comprehensive and accurate replay.
  3. Consider using this in conjunction with other demo-related console variables like demo.LateDestructionInfoPrioritize for fine-tuned control over the demo recording process.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:141

Scope (from outer to inner):

file
namespace    DemoNetDriverRecordingPrivate

Source code excerpt:


	static TAutoConsoleVariable<int32> CVarDemoForcePersistentLevelPriority(TEXT("demo.ForcePersistentLevelPriority"), 0, TEXT("If true, force persistent level to record first when prioritizing and using streaming level fixes."));
	static TAutoConsoleVariable<int32> CVarDemoDestructionInfoPriority(TEXT("demo.DestructionInfoPriority"), MAX_int32, TEXT("Replay net priority assigned to destruction infos during recording."));
	static TAutoConsoleVariable<int32> CVarDemoLateDestructionInfoPrioritize(TEXT("demo.LateDestructionInfoPrioritize"), 0, TEXT("If true, process destruction infos at the end of the prioritization phase."));
	static TAutoConsoleVariable<float> CVarDemoViewTargetPriorityScale(TEXT("demo.ViewTargetPriorityScale"), 3.0, TEXT("Scale view target priority by this value when prioritization is enabled."));
	static TAutoConsoleVariable<float> CVarDemoMaximumRecDestructionInfoTime(TEXT("demo.MaximumRecDestructionInfoTime"), 0.2, TEXT("Maximum percentage of frame to use replicating destruction infos, if per frame limit is enabled."));
	
	static FAutoConsoleCommandWithWorldAndArgs DemoMaxDesiredRecordTimeMS(
		TEXT("Demo.MaxDesiredRecordTimeMS"),

#Associated Variable and Callsites

This variable is associated with another variable named CVarDemoDestructionInfoPriority. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:141

Scope (from outer to inner):

file
namespace    DemoNetDriverRecordingPrivate

Source code excerpt:


	static TAutoConsoleVariable<int32> CVarDemoForcePersistentLevelPriority(TEXT("demo.ForcePersistentLevelPriority"), 0, TEXT("If true, force persistent level to record first when prioritizing and using streaming level fixes."));
	static TAutoConsoleVariable<int32> CVarDemoDestructionInfoPriority(TEXT("demo.DestructionInfoPriority"), MAX_int32, TEXT("Replay net priority assigned to destruction infos during recording."));
	static TAutoConsoleVariable<int32> CVarDemoLateDestructionInfoPrioritize(TEXT("demo.LateDestructionInfoPrioritize"), 0, TEXT("If true, process destruction infos at the end of the prioritization phase."));
	static TAutoConsoleVariable<float> CVarDemoViewTargetPriorityScale(TEXT("demo.ViewTargetPriorityScale"), 3.0, TEXT("Scale view target priority by this value when prioritization is enabled."));
	static TAutoConsoleVariable<float> CVarDemoMaximumRecDestructionInfoTime(TEXT("demo.MaximumRecDestructionInfoTime"), 0.2, TEXT("Maximum percentage of frame to use replicating destruction infos, if per frame limit is enabled."));
	
	static FAutoConsoleCommandWithWorldAndArgs DemoMaxDesiredRecordTimeMS(
		TEXT("Demo.MaxDesiredRecordTimeMS"),

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DemoNetDriver.cpp:1916

Scope (from outer to inner):

file
function     void UDemoNetDriver::TickDemoRecordFrame
lambda-function

Source code excerpt:

			// Add destroyed actors that the client may not have a channel for
			FDemoActorPriority DestroyedActorPriority;
			DestroyedActorPriority.ActorPriority.Priority = DemoNetDriverRecordingPrivate::CVarDemoDestructionInfoPriority.GetValueOnAnyThread();

			for (auto DestroyedOrDormantGUID = ClientConnection->GetDestroyedStartupOrDormantActorGUIDs().CreateIterator(); DestroyedOrDormantGUID; ++DestroyedOrDormantGUID)
			{
				TUniquePtr<FActorDestructionInfo>& DInfo = DestroyedStartupOrDormantActors.FindChecked(*DestroyedOrDormantGUID);
				DestroyedActorPriority.ActorPriority.DestructionInfo = DInfo.Get();
				DestroyedActorPriority.Level = HasLevelStreamingFixes() ? DestroyedActorPriority.ActorPriority.DestructionInfo->Level.Get() : nullptr;