s.AdaptiveAddToWorld.Method

s.AdaptiveAddToWorld.Method

#Overview

name: s.AdaptiveAddToWorld.Method

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 s.AdaptiveAddToWorld.Method is to control the heuristic used for the adaptive timeslice in Unreal Engine’s level streaming system. This setting variable is part of the engine’s level streaming and world management system.

This setting variable is primarily used in the Engine module, specifically in the world management subsystem. It’s referenced in the World.cpp file, which is a core part of Unreal Engine’s world handling system.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1 and can be changed at runtime using console commands or through configuration files.

The variable interacts closely with GAdaptiveAddToWorldMethod, which is the C++ variable that directly stores the value set by s.AdaptiveAddToWorld.Method. They share the same value and purpose.

Developers should be aware that this variable affects how the engine calculates the timeslice for adding actors to the world during level streaming. It offers two methods: 0 - Compute the target timeslice based on remaining work time 1 - Compute the target timeslice based on total work time for levels in flight (this avoids slowing before a level completes)

Best practices when using this variable include:

  1. Understanding the implications of each method on performance and level streaming behavior.
  2. Testing both methods in your specific use case to determine which works best for your game.
  3. Monitoring performance metrics related to level streaming when adjusting this value.

Regarding the associated variable GAdaptiveAddToWorldMethod:

The purpose of GAdaptiveAddToWorldMethod is to store the actual value of the adaptive add-to-world method within the C++ code. It directly corresponds to the s.AdaptiveAddToWorld.Method console variable.

This variable is used in the Engine module, specifically in the world management and level streaming systems.

The value of GAdaptiveAddToWorldMethod is set by the console variable system when s.AdaptiveAddToWorld.Method is changed.

It interacts directly with s.AdaptiveAddToWorld.Method, as they represent the same setting in different contexts (console variable vs. C++ variable).

Developers should be aware that this is the actual variable used in the C++ code to determine the behavior of the adaptive timeslice calculation. Changes to s.AdaptiveAddToWorld.Method will be reflected in this variable.

Best practices for using GAdaptiveAddToWorldMethod include:

  1. Not modifying this variable directly in C++ code, but instead using the console variable system to ensure consistency.
  2. Using this variable for read-only purposes in C++ code when implementing or modifying level streaming behavior.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:165

Scope: file

Source code excerpt:


static int32 GAdaptiveAddToWorldMethod = 1;
FAutoConsoleVariableRef CVarAdaptiveAddToWorldMethod(TEXT("s.AdaptiveAddToWorld.Method"), GAdaptiveAddToWorldMethod,
	TEXT("Heuristic to use for the adaptive timeslice\n")
	TEXT("0 - compute the target timeslice based on remaining work time\n")
	TEXT("1 - compute the target timeslice based on total work time for levels in flight (this avoids slowing before a level completes)\n"));

static float GAdaptiveAddToWorldTimeSliceMin = 1.0f;
FAutoConsoleVariableRef CVarAdaptiveAddToWorldTimeSliceMin(TEXT("s.AdaptiveAddToWorld.AddToWorldTimeSliceMin"), GAdaptiveAddToWorldTimeSliceMin, 

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:164

Scope: file

Source code excerpt:

	TEXT("Enables the adaptive AddToWorld timeslice (replaces s.LevelStreamingActorsUpdateTimeLimit) (default: off)"));

static int32 GAdaptiveAddToWorldMethod = 1;
FAutoConsoleVariableRef CVarAdaptiveAddToWorldMethod(TEXT("s.AdaptiveAddToWorld.Method"), GAdaptiveAddToWorldMethod,
	TEXT("Heuristic to use for the adaptive timeslice\n")
	TEXT("0 - compute the target timeslice based on remaining work time\n")
	TEXT("1 - compute the target timeslice based on total work time for levels in flight (this avoids slowing before a level completes)\n"));

static float GAdaptiveAddToWorldTimeSliceMin = 1.0f;
FAutoConsoleVariableRef CVarAdaptiveAddToWorldTimeSliceMin(TEXT("s.AdaptiveAddToWorld.AddToWorldTimeSliceMin"), GAdaptiveAddToWorldTimeSliceMin, 

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:272

Scope (from outer to inner):

file
class        class FAdaptiveAddToWorld
function     void EndUpdate

Source code excerpt:

				// Work out what the timeslice should be
				float TargetTimeSlice = 0.0f;
				if (GAdaptiveAddToWorldMethod == 1)
				{
					float EstimatedTotalTimeForCurrentLevelsWith1MsTimeSlice = (float)TotalWorkUnitsForLevelsInFlight / AverageWorkUnitsPerSecondWith1MsTimeSlice;
					CSV_CUSTOM_STAT(LevelStreamingAdaptiveDetail, EstimatedTotalTimeForCurrentLevelsWith1MsTimeSlice, EstimatedTotalTimeForCurrentLevelsWith1MsTimeSlice, ECsvCustomStatOp::Set);
					TargetTimeSlice = EstimatedTotalTimeForCurrentLevelsWith1MsTimeSlice / GAdaptiveAddToWorldTargetMaxTimeRemaining - ExtraTimeSlice;
				}
				else