landscape.ApplyPhysicalMaterialChangesImmediately

landscape.ApplyPhysicalMaterialChangesImmediately

#Overview

name: landscape.ApplyPhysicalMaterialChangesImmediately

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.ApplyPhysicalMaterialChangesImmediately is to control when physical material changes are applied to the landscape in Unreal Engine 5. It determines whether these changes should be applied immediately or deferred until the next cook or Play-in-Editor (PIE) session.

This setting variable is primarily used by the Landscape module within Unreal Engine’s rendering system. It affects how physical material changes are handled for landscape components.

The value of this variable is set using a console variable (CVar) system. It’s initialized with a default value of 1, meaning that changes are applied immediately by default.

The associated variable CVarLandscapeApplyPhysicalMaterialChangesImmediately interacts directly with this setting. It’s an instance of TAutoConsoleVariable that provides access to the value of landscape.ApplyPhysicalMaterialChangesImmediately within the C++ code.

Developers should be aware that:

  1. This variable affects performance and behavior in the editor.
  2. Setting it to 0 will defer physical material changes, potentially improving editor performance but delaying visual updates.
  3. It’s primarily relevant in editor workflows and doesn’t affect runtime behavior in packaged games.

Best practices when using this variable include:

  1. Keep it enabled (set to 1) during active landscape editing for immediate visual feedback.
  2. Consider disabling it (set to 0) when working on large landscapes or if experiencing performance issues in the editor.
  3. Remember to re-enable it before final builds or when precise physical material representation is crucial for testing.

Regarding the associated variable CVarLandscapeApplyPhysicalMaterialChangesImmediately:

When working with CVarLandscapeApplyPhysicalMaterialChangesImmediately, developers should:

  1. Use GetValueOnGameThread() to safely retrieve the current value.
  2. Be aware that changes to this variable will immediately affect landscape editing behavior.
  3. Consider exposing this option in custom editor tools if fine-grained control over landscape physical material updates is needed.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEdit.cpp:103

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarLandscapeApplyPhysicalMaterialChangesImmediately(
    TEXT("landscape.ApplyPhysicalMaterialChangesImmediately"),
	1,
    TEXT("Applies physical material task changes immediately rather than during the next cook/PIE."));

#if WITH_EDITOR

// Used to temporarily disable material instance updates (typically used for cases where multiple updates are called on sample component)

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEdit.cpp:102

Scope: file

Source code excerpt:

#define LOCTEXT_NAMESPACE "Landscape"

static TAutoConsoleVariable<int32> CVarLandscapeApplyPhysicalMaterialChangesImmediately(
    TEXT("landscape.ApplyPhysicalMaterialChangesImmediately"),
	1,
    TEXT("Applies physical material task changes immediately rather than during the next cook/PIE."));

#if WITH_EDITOR

#Loc: <Workspace>/Engine/Source/Runtime/Landscape/Private/LandscapeEdit.cpp:2116

Scope (from outer to inner):

file
function     void ULandscapeComponent::UpdatePhysicalMaterialTasks

Source code excerpt:

			// Potentially, we do not force an update of the physics data here (behind a CVar, as we don't necessarily need the 
			//  information immediately in the editor and update will happen on cook or PIE) :
			FinalizePhysicalMaterial(CVarLandscapeApplyPhysicalMaterialChangesImmediately.GetValueOnGameThread() != 0);
		}
		else
		{
			PhysicalMaterialTask.Tick();
		}
	}