s.AdaptiveAddToWorld.Enabled
s.AdaptiveAddToWorld.Enabled
#Overview
name: s.AdaptiveAddToWorld.Enabled
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enables the adaptive AddToWorld timeslice (replaces s.LevelStreamingActorsUpdateTimeLimit) (default: off)
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of s.AdaptiveAddToWorld.Enabled is to control the adaptive AddToWorld timeslice feature in Unreal Engine 5’s level streaming system. This setting variable is primarily used for optimizing the process of adding actors to the world during level streaming.
The Unreal Engine subsystem that relies on this setting variable is the level streaming system, which is part of the Engine module. This can be seen from the file locations where the variable is referenced: Engine/Source/Runtime/Engine/Private/World.cpp and Engine/Source/Runtime/Engine/Classes/Engine/Level.h.
The value of this variable is set through a console variable (CVar) system. It’s initialized to 0 (disabled) by default, but can be changed at runtime using the console command “s.AdaptiveAddToWorld.Enabled”.
This variable interacts closely with GAdaptiveAddToWorldEnabled, which is the internal C++ variable that stores the actual value. They share the same value, with s.AdaptiveAddToWorld.Enabled being the console-accessible name.
Developers must be aware that enabling this feature replaces the functionality of another setting, s.LevelStreamingActorsUpdateTimeLimit. This is important to note to avoid conflicts or unexpected behavior when tuning level streaming performance.
Best practices when using this variable include:
- Use it when you need to optimize level streaming performance, especially in scenarios with many actors or complex levels.
- Monitor its impact on performance, as adaptive timeslicing can affect frame rates and loading times.
- Test thoroughly with different values (0 or 1) to determine the best setting for your specific game scenario.
Regarding the associated variable GAdaptiveAddToWorldEnabled:
The purpose of GAdaptiveAddToWorldEnabled is to serve as the internal C++ representation of the s.AdaptiveAddToWorld.Enabled setting. It’s used directly in the engine code to control the behavior of the adaptive AddToWorld feature.
This variable is part of the Engine module and is used in the World updating process, specifically in the UpdateLevelStreaming function.
The value of GAdaptiveAddToWorldEnabled is set indirectly through the console variable system when s.AdaptiveAddToWorld.Enabled is modified.
GAdaptiveAddToWorldEnabled interacts with the GAdaptiveAddToWorld object, which likely encapsulates the adaptive AddToWorld functionality. The SetEnabled method of this object is called with the value of GAdaptiveAddToWorldEnabled.
Developers should be aware that this variable is not meant to be modified directly in code. Instead, they should use the console variable s.AdaptiveAddToWorld.Enabled to control this feature.
Best practices for GAdaptiveAddToWorldEnabled include:
- Avoid modifying it directly in C++ code; use the console variable instead.
- When reading its value in code, be aware that it may change at runtime due to console commands.
- Consider its value when debugging level streaming issues or performance problems related to adding actors to the world.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:161
Scope: file
Source code excerpt:
-----------------------------------------------------------------------------*/
static int32 GAdaptiveAddToWorldEnabled = 0;
FAutoConsoleVariableRef CVarAdaptiveAddToWorldEnabled(TEXT("s.AdaptiveAddToWorld.Enabled"), GAdaptiveAddToWorldEnabled,
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")
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/Engine/Level.h:1355
Scope: file
Source code excerpt:
//~ End IInterface_AssetUserData Interface
/** Estimate the amount of AddToWorld work for this level. Used by the adaptive level streaming timeslice (see s.AdaptiveAddToWorld.Enabled) */
int32 GetEstimatedAddToWorldWorkUnitsRemaining() const;
/** Estimate the total amount of AddToWorld work for this level. Used by the adaptive level streaming timeslice (see s.AdaptiveAddToWorld.Enabled) */
int32 GetEstimatedAddToWorldWorkUnitsTotal() const;
#if WITH_EDITOR
/** meant to be called only from editor, calculating and storing static geometry to be used with off-line and/or on-line navigation building */
ENGINE_API void RebuildStaticNavigableGeometry();
#Associated Variable and Callsites
This variable is associated with another variable named GAdaptiveAddToWorldEnabled
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:160
Scope: file
Source code excerpt:
FAdaptiveAddToWorld implementation.
-----------------------------------------------------------------------------*/
static int32 GAdaptiveAddToWorldEnabled = 0;
FAutoConsoleVariableRef CVarAdaptiveAddToWorldEnabled(TEXT("s.AdaptiveAddToWorld.Enabled"), GAdaptiveAddToWorldEnabled,
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")
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/World.cpp:4295
Scope (from outer to inner):
file
function void UWorld::UpdateLevelStreaming
Source code excerpt:
}
GAdaptiveAddToWorld.SetEnabled(GAdaptiveAddToWorldEnabled == 1);
if ( GAdaptiveAddToWorld.IsEnabled() )
{
GAdaptiveAddToWorld.BeginUpdate();
}