landscape.ValidateProxyWeightmapUsages

landscape.ValidateProxyWeightmapUsages

#Overview

name: landscape.ValidateProxyWeightmapUsages

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 landscape.ValidateProxyWeightmapUsages is to control the validation of weightmap usages in landscape proxies and their components. This setting ensures that these usages remain synchronized with the landscape component layer allocations.

This setting variable is primarily used in the Landscape system of Unreal Engine 5. It’s specifically utilized in the landscape editing and rendering subsystem.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1, which means the validation is enabled by default.

The associated variable CVarLandscapeValidateProxyWeightmapUsages directly interacts with landscape.ValidateProxyWeightmapUsages. They share the same value and purpose.

Developers must be aware that this variable affects the performance and accuracy of landscape rendering. When enabled (set to 1), it performs additional checks to ensure the consistency of weightmap usages, which could have a minor performance impact.

Best practices when using this variable include:

  1. Keep it enabled (value 1) during development to catch any desynchronization issues early.
  2. Consider disabling it (value 0) in production builds if performance is a critical concern and you’re confident in the landscape data integrity.
  3. Use it in conjunction with other landscape debugging tools to ensure proper landscape rendering and editing.

Regarding the associated variable CVarLandscapeValidateProxyWeightmapUsages:

The purpose of CVarLandscapeValidateProxyWeightmapUsages is the same as landscape.ValidateProxyWeightmapUsages. It’s the C++ representation of the console variable.

This variable is used in the ALandscapeProxy::ValidateProxyLayersWeightmapUsage function to determine whether to perform the validation check.

The value is set and retrieved using the CVar system, specifically with GetValueOnGameThread().

It interacts directly with the bTemporarilyDisableWeightmapUsagesValidation flag, which can override the CVar setting.

Developers should be aware that this variable’s value is checked on the game thread, which means changes to it will take effect on the next frame.

Best practices include:

  1. Use this variable for fine-grained control over validation in specific parts of the code.
  2. Consider the performance implications of frequent checks in performance-critical sections.
  3. Use it in combination with bTemporarilyDisableWeightmapUsagesValidation for more complex validation logic if needed.

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarLandscapeValidateProxyWeightmapUsages(
	TEXT("landscape.ValidateProxyWeightmapUsages"),
	1,
	TEXT("This will validate that weightmap usages in landscape proxies and their components don't get desynchronized with the landscape component layer allocations."));

TAutoConsoleVariable<int32> CVarLandscapeRemoveEmptyPaintLayersOnEdit(
	TEXT("landscape.RemoveEmptyPaintLayersOnEdit"),
	// TODO [jonathan.bard] : this has been disabled for now, since it can lead to a permanent dirty-on-load state for landscape, where the edit layers will do a new weightmap allocation for the missing layer

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	TEXT("This will force a render flush every frame when landscape editing."));

TAutoConsoleVariable<int32> CVarLandscapeValidateProxyWeightmapUsages(
	TEXT("landscape.ValidateProxyWeightmapUsages"),
	1,
	TEXT("This will validate that weightmap usages in landscape proxies and their components don't get desynchronized with the landscape component layer allocations."));

TAutoConsoleVariable<int32> CVarLandscapeRemoveEmptyPaintLayersOnEdit(
	TEXT("landscape.RemoveEmptyPaintLayersOnEdit"),

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

Scope (from outer to inner):

file
function     void ALandscapeProxy::ValidateProxyLayersWeightmapUsage

Source code excerpt:

void ALandscapeProxy::ValidateProxyLayersWeightmapUsage() const
{
	if ((CVarLandscapeValidateProxyWeightmapUsages.GetValueOnGameThread() == 0) || bTemporarilyDisableWeightmapUsagesValidation)
	{
		return;
	}

	// Fixup and usages should have been updated any time we run validation
	check(WeightmapFixupVersion == CurrentVersion);