landscape.ForceLayersUpdate

landscape.ForceLayersUpdate

#Overview

name: landscape.ForceLayersUpdate

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

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of landscape.ForceLayersUpdate is to control the update frequency of landscape edit layers in Unreal Engine 5. It is primarily used for the landscape rendering and editing system.

This setting variable is primarily used in the Landscape module of Unreal Engine 5. Based on the callsites, it’s clear that this variable is utilized in the landscape editing and rendering processes, specifically in the ALandscape class.

The value of this variable is set as a console variable, which means it can be changed at runtime. It is initialized with a default value of 0.

The associated variable CVarForceLayersUpdate directly interacts with landscape.ForceLayersUpdate. They share the same value and are used interchangeably in the code.

Developers must be aware that when this variable is set to a non-zero value, it will force landscape edit layers to update every frame, rather than only when requested. This can have performance implications, especially for large or complex landscapes.

Best practices when using this variable include:

  1. Keep it disabled (set to 0) during normal gameplay to maintain optimal performance.
  2. Enable it (set to 1) only when debugging or when immediate updates to landscape layers are necessary.
  3. Be cautious about enabling this in production builds, as it may impact performance.

Regarding the associated variable CVarForceLayersUpdate:

The purpose of CVarForceLayersUpdate is to provide a programmatic way to access and modify the landscape.ForceLayersUpdate setting within C++ code.

It is used in the same Landscape module and is typically checked in functions related to regenerating landscape heightmaps and weightmaps, as well as updating layer content.

The value of CVarForceLayersUpdate is set when the console variable landscape.ForceLayersUpdate is modified.

CVarForceLayersUpdate directly interacts with landscape.ForceLayersUpdate, effectively serving as its C++ representation.

Developers should be aware that changes to CVarForceLayersUpdate will affect the behavior of landscape layer updates throughout the engine.

Best practices for CVarForceLayersUpdate include:

  1. Use GetValueOnAnyThread() to safely access its value from any thread.
  2. Consider the performance implications when enabling this feature, especially in performance-critical sections of code.
  3. Use it judiciously, primarily for debugging or development purposes, rather than in shipping builds.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEditLayers.cpp:89

Scope: file

Source code excerpt:

#if WITH_EDITOR
static TAutoConsoleVariable<int32> CVarForceLayersUpdate(
	TEXT("landscape.ForceLayersUpdate"),
	0,
	TEXT("This will force landscape edit layers to be update every frame, rather than when requested only."));

int32 RenderCaptureLayersNextHeightmapDraws = 0;
static FAutoConsoleVariableRef CVarRenderCaptureLayersNextHeightmapDraws(
	TEXT("landscape.RenderCaptureLayersNextHeightmapDraws"),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEditLayers.cpp:88

Scope: file

Source code excerpt:


#if WITH_EDITOR
static TAutoConsoleVariable<int32> CVarForceLayersUpdate(
	TEXT("landscape.ForceLayersUpdate"),
	0,
	TEXT("This will force landscape edit layers to be update every frame, rather than when requested only."));

int32 RenderCaptureLayersNextHeightmapDraws = 0;
static FAutoConsoleVariableRef CVarRenderCaptureLayersNextHeightmapDraws(

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEditLayers.cpp:5079

Scope (from outer to inner):

file
function     int32 ALandscape::RegenerateLayersHeightmaps

Source code excerpt:

	const int32 AllHeightmapUpdateModes = (ELandscapeLayerUpdateMode::Update_Heightmap_All | ELandscapeLayerUpdateMode::Update_Heightmap_Editing | ELandscapeLayerUpdateMode::Update_Heightmap_Editing_NoCollision);
	const int32 HeightmapUpdateModes = LayerContentUpdateModes & AllHeightmapUpdateModes;
	const bool bForceRender = CVarForceLayersUpdate.GetValueOnAnyThread() != 0;
	const bool bSkipBrush = CVarLandscapeLayerBrushOptim.GetValueOnAnyThread() == 1 && ((HeightmapUpdateModes & AllHeightmapUpdateModes) == ELandscapeLayerUpdateMode::Update_Heightmap_Editing);

	if ((HeightmapUpdateModes == 0 && !bForceRender) || Info == nullptr)
	{
		return 0;
	}

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEditLayers.cpp:7575

Scope (from outer to inner):

file
function     int32 ALandscape::RegenerateLayersWeightmaps

Source code excerpt:

	const int32 WeightmapUpdateModes = LayerContentUpdateModes & AllWeightmapUpdateModes;
	const bool bSkipBrush = CVarLandscapeLayerBrushOptim.GetValueOnAnyThread() == 1 && ((WeightmapUpdateModes & AllWeightmapUpdateModes) == ELandscapeLayerUpdateMode::Update_Weightmap_Editing);
	const bool bForceRender = CVarForceLayersUpdate.GetValueOnAnyThread() != 0;

	ULandscapeInfo* Info = GetLandscapeInfo();

	if (WeightmapUpdateModes == 0 && !bForceRender)
	{
		return 0;

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEditLayers.cpp:8337

Scope (from outer to inner):

file
function     void ALandscape::UpdateLayersContent

Source code excerpt:


	const bool bProcessReadbacks = FLandscapeEditLayerReadback::HasWork();
	const bool bForceRender = CVarForceLayersUpdate.GetValueOnAnyThread() != 0;

	// User triggered change has been completely processed, resetting user triggered flag on all components.
	if (!bProcessReadbacks && (LayerContentUpdateModes == 0))
	{
		GetLandscapeInfo()->ForAllLandscapeComponents(
			[this](ULandscapeComponent* Component) -> void