landscape.Optim
landscape.Optim
#Overview
name: landscape.Optim
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
This will enable landscape layers optim.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of landscape.Optim is to enable landscape layer optimization in Unreal Engine 5. This setting variable is primarily used for the landscape system, which is responsible for rendering and managing large-scale terrain in games and applications.
The Unreal Engine subsystem that relies on this setting variable is the Landscape module, specifically the landscape editing and rendering components. This can be seen from the file location where the variable is defined: Engine/Source/Runtime/Landscape/Private/LandscapeEditLayers.cpp
.
The value of this variable is set using a console variable (CVar) system. It’s initialized with a default value of 1, meaning the optimization is enabled by default. Developers can change this value at runtime using console commands or through game code.
The associated variable CVarLandscapeLayerOptim interacts directly with landscape.Optim. They share the same value and purpose, with CVarLandscapeLayerOptim being the C++ representation of the console variable.
Developers must be aware that this variable affects the performance and behavior of landscape layer operations. When enabled (set to 1), it allows for partial updates of landscape layers, which can significantly improve performance, especially for large landscapes or frequent updates.
Best practices when using this variable include:
- Keep it enabled (value 1) for better performance in most cases.
- If experiencing issues with landscape layer updates, try disabling it (set to 0) to see if it resolves the problem.
- Consider exposing this setting in your game’s options menu for advanced users or debugging purposes.
- When making changes to landscape systems, always test with both enabled and disabled states to ensure compatibility.
Regarding the associated variable CVarLandscapeLayerOptim:
The purpose of CVarLandscapeLayerOptim is to provide programmatic access to the landscape.Optim setting within the C++ code of Unreal Engine.
It’s used in the Landscape module, specifically in landscape editing and rendering operations. The value is set through the console variable system, initialized to 1 by default.
This variable is used directly in the code to determine whether to perform partial updates on landscape layers. For example, in the ALandscape::UpdateLayersContent
function, it’s used to set the bPartialUpdate
flag:
bool bPartialUpdate = !bForceRender && !bUpdateAll && CVarLandscapeLayerOptim.GetValueOnAnyThread() == 1;
Developers should be aware that changes to this variable will immediately affect landscape rendering behavior. It’s important to use the GetValueOnAnyThread()
method when accessing the value, as shown in the code example, to ensure thread-safe access.
Best practices for using CVarLandscapeLayerOptim include:
- Use it to dynamically toggle landscape optimization in response to game events or performance requirements.
- Consider caching the value if it’s accessed frequently, to avoid repeated calls to
GetValueOnAnyThread()
. - When modifying landscape-related code, always check if this optimization is enabled and test both cases.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEditLayers.cpp:121
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarLandscapeLayerOptim(
TEXT("landscape.Optim"),
1,
TEXT("This will enable landscape layers optim."));
static TAutoConsoleVariable<int32> CVarLandscapeLayerBrushOptim(
TEXT("landscape.BrushOptim"),
0,
#Associated Variable and Callsites
This variable is associated with another variable named CVarLandscapeLayerOptim
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEditLayers.cpp:120
Scope: file
Source code excerpt:
TEXT("This will enable physic simulation on worlds containing landscape."));
static TAutoConsoleVariable<int32> CVarLandscapeLayerOptim(
TEXT("landscape.Optim"),
1,
TEXT("This will enable landscape layers optim."));
static TAutoConsoleVariable<int32> CVarLandscapeLayerBrushOptim(
TEXT("landscape.BrushOptim"),
#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEditLayers.cpp:8457
Scope (from outer to inner):
file
function void ALandscape::UpdateLayersContent
Source code excerpt:
bool bUpdateAll = LayerContentUpdateModes & Update_All;
bool bPartialUpdate = !bForceRender && !bUpdateAll && CVarLandscapeLayerOptim.GetValueOnAnyThread() == 1;
FUpdateLayersContentContext UpdateLayersContentContext(MapHelper, bPartialUpdate);
// Regenerate any heightmaps and weightmaps
int32 ProcessedModes = 0;
ProcessedModes |= RegenerateLayersHeightmaps(UpdateLayersContentContext);