r.Water.WaterZoneActor.OverrideNewWaterZoneScale

r.Water.WaterZoneActor.OverrideNewWaterZoneScale

#Overview

name: r.Water.WaterZoneActor.OverrideNewWaterZoneScale

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 r.Water.WaterZoneActor.OverrideNewWaterZoneScale is to control the scaling of a WaterZone actor’s extent beyond the landscape boundaries in Unreal Engine 5’s water system.

This setting variable is primarily used by the Water plugin, specifically within the Water Editor module. It’s part of the experimental water system in Unreal Engine 5.

The value of this variable is set through the console variable system. It’s defined as a TAutoConsoleVariable with a default value of 0, which means no override by default.

This variable interacts closely with another console variable, CVarOverrideNewWaterZoneMinimumMargin, which enforces a minimum distance between the landscape and the WaterZone actor extent.

Developers must be aware that this variable only takes effect when creating new WaterZone actors. It doesn’t affect existing WaterZone actors in the scene. Also, a value of 0 means no override, in which case the default value from UWaterEditorSettings is used instead.

Best practices when using this variable include:

  1. Use it sparingly and only when you need to adjust the default behavior.
  2. Be cautious with large values as they might create unnecessarily large water zones.
  3. Consider the performance implications of larger water zones.
  4. Use in conjunction with CVarOverrideNewWaterZoneMinimumMargin for fine-tuned control.

Regarding the associated variable CVarOverrideNewWaterZoneScale:

The purpose of CVarOverrideNewWaterZoneScale is identical to r.Water.WaterZoneActor.OverrideNewWaterZoneScale. It’s the actual C++ variable that stores and provides access to the console variable’s value.

This variable is part of the WaterEditorModule namespace and is used within the FWaterEditorModule class.

The value of this variable is set when the console variable r.Water.WaterZoneActor.OverrideNewWaterZoneScale is set.

It interacts directly with the game thread, as seen in the GetValueOnGameThread() call.

Developers should be aware that this is an internal variable and should generally interact with it through the console variable system rather than directly.

Best practices include using the appropriate console commands to modify this value rather than attempting to change it programmatically, unless there’s a specific need to do so within the engine’s code.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Editor/Private/WaterEditorModule.cpp:37

Scope (from outer to inner):

file
namespace    WaterEditorModule

Source code excerpt:

namespace WaterEditorModule
{
	static TAutoConsoleVariable<float> CVarOverrideNewWaterZoneScale(TEXT("r.Water.WaterZoneActor.OverrideNewWaterZoneScale"), 0, TEXT("Multiply WaterZone actor extent beyond landscape by this amount. 0 means no override."));
	static TAutoConsoleVariable<float> CVarOverrideNewWaterZoneMinimumMargin(TEXT("r.Water.WaterZoneActor.OverrideNewWaterZoneMinimumMargin"), 0, TEXT("Enforce a minimum distance between landscape and the WaterZone actor extent. 0 means no override."));
}

void FWaterEditorModule::StartupModule()
{
	FWaterUIStyle::Initialize();

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Editor/Private/WaterEditorModule.cpp:37

Scope (from outer to inner):

file
namespace    WaterEditorModule

Source code excerpt:

namespace WaterEditorModule
{
	static TAutoConsoleVariable<float> CVarOverrideNewWaterZoneScale(TEXT("r.Water.WaterZoneActor.OverrideNewWaterZoneScale"), 0, TEXT("Multiply WaterZone actor extent beyond landscape by this amount. 0 means no override."));
	static TAutoConsoleVariable<float> CVarOverrideNewWaterZoneMinimumMargin(TEXT("r.Water.WaterZoneActor.OverrideNewWaterZoneMinimumMargin"), 0, TEXT("Enforce a minimum distance between landscape and the WaterZone actor extent. 0 means no override."));
}

void FWaterEditorModule::StartupModule()
{
	FWaterUIStyle::Initialize();

#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Editor/Private/WaterEditorModule.cpp:293

Scope (from outer to inner):

file
function     void FWaterEditorModule::OnLevelActorAddedToWorld

Source code excerpt:

							FVector2D NewExtent = 2 * FVector2D(WaterZoneBounds.GetExtent());

							float ZoneExtentScale = WaterEditorModule::CVarOverrideNewWaterZoneScale.GetValueOnGameThread();
							const float MinimumMargin = WaterEditorModule::CVarOverrideNewWaterZoneMinimumMargin.GetValueOnGameThread();

							if (ZoneExtentScale == 0)
							{
								ZoneExtentScale = GetDefault<UWaterEditorSettings>()->WaterZoneActorDefaults.NewWaterZoneScale;
							}