r.Water.UseBuoyancyAsyncPath

r.Water.UseBuoyancyAsyncPath

#Overview

name: r.Water.UseBuoyancyAsyncPath

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.UseBuoyancyAsyncPath is to control whether the buoyancy calculations in the Water system use an asynchronous physics callback. This setting is part of the Water plugin’s buoyancy system in Unreal Engine 5.

This setting variable is primarily used by the Experimental Water plugin, specifically within the BuoyancyComponent. The Water plugin and its associated buoyancy system rely on this variable to determine the execution path for buoyancy calculations.

The value of this variable is set through a console variable (CVarWaterBuoyancyUseAsyncPath) defined in the BuoyancyComponent.cpp file. It is initialized with a default value of 1, meaning the async path is enabled by default.

The associated variable CVarWaterBuoyancyUseAsyncPath directly interacts with r.Water.UseBuoyancyAsyncPath. They share the same value and purpose, with CVarWaterBuoyancyUseAsyncPath being the actual console variable implementation.

Developers must be aware that this variable affects the performance and behavior of the buoyancy system. Using the async path can potentially improve performance by offloading buoyancy calculations to a separate thread, but it may also introduce some latency or synchronization issues in certain scenarios.

Best practices when using this variable include:

  1. Testing both async and sync paths to determine which performs better for your specific use case.
  2. Monitoring performance metrics when changing this setting to ensure it benefits your game’s performance.
  3. Being cautious when modifying this setting at runtime, as it may affect ongoing physics simulations.

Regarding the associated variable CVarWaterBuoyancyUseAsyncPath:

#References in C++ code

#Callsites

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

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

Scope: file

Source code excerpt:


TAutoConsoleVariable<int32> CVarWaterBuoyancyUseAsyncPath(
	TEXT("r.Water.UseBuoyancyAsyncPath"),
	1,
	TEXT("Whether to use async physics callback for buoyancy."),
	ECVF_Default);

UBuoyancyComponent::UBuoyancyComponent(const FObjectInitializer& ObjectInitializer)
	: Super(ObjectInitializer)

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

	ECVF_Default);

TAutoConsoleVariable<int32> CVarWaterBuoyancyUseAsyncPath(
	TEXT("r.Water.UseBuoyancyAsyncPath"),
	1,
	TEXT("Whether to use async physics callback for buoyancy."),
	ECVF_Default);

UBuoyancyComponent::UBuoyancyComponent(const FObjectInitializer& ObjectInitializer)

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

Scope (from outer to inner):

file
function     bool UBuoyancyComponent::IsUsingAsyncPath

Source code excerpt:

		}
	}
	return bAsyncSolver && bUseAsyncPath && (CVarWaterBuoyancyUseAsyncPath.GetValueOnAnyThread() > 0);
}

TUniquePtr<FBuoyancyComponentAsyncAux> UBuoyancyComponent::CreateAsyncAux() const
{
	TUniquePtr<FBuoyancyComponentBaseAsyncAux> Aux = MakeUnique<FBuoyancyComponentBaseAsyncAux>();
	Aux->BuoyancyData = BuoyancyData;