r.Water.OverrideWavesTime

r.Water.OverrideWavesTime

#Overview

name: r.Water.OverrideWavesTime

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.OverrideWavesTime is to control the time used for water wave animations in Unreal Engine’s water simulation system. This setting variable is part of the experimental Water plugin and is used specifically for debugging and testing purposes.

This setting variable is primarily used in the Water plugin, which is an experimental module in Unreal Engine 5. The main subsystem that relies on this variable is the WaterSubsystem, as seen in the provided code snippets.

The value of this variable is set through the console variable system in Unreal Engine. It’s defined as a TAutoConsoleVariable with a default value of -1.0f. The value can be changed at runtime using console commands or through code.

The associated variable CVarOverrideWavesTime directly interacts with r.Water.OverrideWavesTime. They share the same value and purpose.

Developers must be aware of several things when using this variable:

  1. It’s marked as a cheat variable (ECVF_Cheat), indicating it’s intended for debugging and testing, not for use in production builds.
  2. The variable only takes effect when its value is greater than or equal to 0.0.
  3. When active, it overrides the normal time calculation for water waves, which could affect the visual fidelity and behavior of water in the game.

Best practices when using this variable include:

  1. Use it only for debugging and testing purposes, not in production builds.
  2. Be cautious when overriding the wave time, as it may create unrealistic water behavior.
  3. Remember to reset the value to -1.0f (or use the console to clear the override) when finished testing to return to normal water simulation behavior.

Regarding the associated variable CVarOverrideWavesTime: Its purpose is to provide a programmatic way to access and modify the r.Water.OverrideWavesTime setting. It’s used within the WaterSubsystem to check if a time override is in effect and to retrieve the override value. The GetWaterTimeSeconds() function in the WaterSubsystem uses this variable to determine whether to use the overridden time or the normal world time for water simulations. The same considerations and best practices apply to CVarOverrideWavesTime as to r.Water.OverrideWavesTime.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterSubsystem.cpp:59

Scope: file

Source code excerpt:


static TAutoConsoleVariable<float> CVarOverrideWavesTime(
	TEXT("r.Water.OverrideWavesTime"),
	-1.0f,
	TEXT("Forces the time used for waves if >= 0.0"),
	ECVF_Cheat
);

// Underwater post process CVars : 

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterSubsystem.cpp:58

Scope: file

Source code excerpt:

);

static TAutoConsoleVariable<float> CVarOverrideWavesTime(
	TEXT("r.Water.OverrideWavesTime"),
	-1.0f,
	TEXT("Forces the time used for waves if >= 0.0"),
	ECVF_Cheat
);

#Loc: <Workspace>/Engine/Plugins/Experimental/Water/Source/Runtime/Private/WaterSubsystem.cpp:416

Scope (from outer to inner):

file
function     float UWaterSubsystem::GetWaterTimeSeconds

Source code excerpt:

float UWaterSubsystem::GetWaterTimeSeconds() const
{
	float ForceWavesTimeValue = CVarOverrideWavesTime.GetValueOnGameThread();
	if (ForceWavesTimeValue >= 0.0f)
	{
		return ForceWavesTimeValue;
	}

	if (UWorld* World = GetWorld())