p.UseAsyncInterpolation

p.UseAsyncInterpolation

#Overview

name: p.UseAsyncInterpolation

This variable is created as a Console Variable (cvar).

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of p.UseAsyncInterpolation is to control whether interpolation should be used when async physics mode is enabled in Unreal Engine’s Chaos physics system. This setting is primarily used in the physics simulation subsystem of Unreal Engine 5.

The Chaos physics module, which is part of the Experimental namespace in Unreal Engine, relies on this setting variable. It is used in the FPhysicsSolverBase class, which is a core component of the Chaos physics solver.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be changed at runtime through console commands. It is initialized with a default value of 1 (enabled).

The UseAsyncInterpolation variable interacts with other physics-related variables, such as ForceDisableAsyncPhysics and GSingleThreadedPhysics. It is also used in conjunction with IsUsingAsyncResults() to determine if fixed delta time should be used in physics calculations.

Developers must be aware that this variable affects the behavior of async physics simulations. When enabled, it allows for interpolation of physics results, which can provide smoother visual results but may have performance implications.

Best practices when using this variable include:

  1. Understanding the trade-offs between visual smoothness and performance.
  2. Testing the game with both enabled and disabled states to ensure it performs well in both scenarios.
  3. Considering the target platform and its capabilities when deciding whether to use async interpolation.

Regarding the associated variable UseAsyncInterpolation:

The purpose of UseAsyncInterpolation is the same as p.UseAsyncInterpolation. It is the internal representation of the console variable within the Chaos physics system.

This variable is used directly in the Chaos physics code, particularly in the FPhysicsSolverBase class. It determines whether to use interpolation for physics results when async mode is enabled.

The value of this variable is set by the console variable p.UseAsyncInterpolation, and they share the same value.

UseAsyncInterpolation interacts with other physics-related functions and variables, such as IsUsingAsyncResults() and GetPhysicsResultsTime_External().

Developers should be aware that this variable directly affects the physics simulation behavior and should be used consistently with the console variable p.UseAsyncInterpolation.

Best practices include ensuring that any code that depends on async interpolation checks this variable before applying interpolation logic, and considering its value when debugging physics-related issues.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Framework/PhysicsSolverBase.cpp:186

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:


	CHAOS_API int32 UseAsyncInterpolation = 1;
	FAutoConsoleVariableRef CVarUseAsyncInterpolation(TEXT("p.UseAsyncInterpolation"), UseAsyncInterpolation, TEXT("Whether to interpolate when async mode is enabled"));

	CHAOS_API int32 ForceDisableAsyncPhysics = 0;
	FAutoConsoleVariableRef CVarForceDisableAsyncPhysics(TEXT("p.ForceDisableAsyncPhysics"), ForceDisableAsyncPhysics, TEXT("Whether to force async physics off regardless of other settings"));

	auto LambdaMul = FConsoleVariableDelegate::CreateLambda([](IConsoleVariable* InVariable)
		{

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Private/Chaos/Framework/PhysicsSolverBase.cpp:185

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:

	}

	CHAOS_API int32 UseAsyncInterpolation = 1;
	FAutoConsoleVariableRef CVarUseAsyncInterpolation(TEXT("p.UseAsyncInterpolation"), UseAsyncInterpolation, TEXT("Whether to interpolate when async mode is enabled"));

	CHAOS_API int32 ForceDisableAsyncPhysics = 0;
	FAutoConsoleVariableRef CVarForceDisableAsyncPhysics(TEXT("p.ForceDisableAsyncPhysics"), ForceDisableAsyncPhysics, TEXT("Whether to force async physics off regardless of other settings"));

	auto LambdaMul = FConsoleVariableDelegate::CreateLambda([](IConsoleVariable* InVariable)
		{

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Framework/PhysicsSolverBase.h:48

Scope (from outer to inner):

file
namespace    Chaos

Source code excerpt:


	extern CHAOS_API int32 GSingleThreadedPhysics;
	extern CHAOS_API int32 UseAsyncInterpolation;
	extern CHAOS_API int32 ForceDisableAsyncPhysics;
	extern CHAOS_API FRealSingle AsyncInterpolationMultiplier;

	struct FSubStepInfo
	{
		FSubStepInfo()

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/Framework/PhysicsSolverBase.h:620

Scope (from outer to inner):

file
namespace    Chaos
class        class FPhysicsSolverBase : public FPhysicsSolverEvents
function     bool IsUsingFixedDt

Source code excerpt:

		bool IsUsingFixedDt() const
		{
			return IsUsingAsyncResults() && UseAsyncInterpolation;
		}

		void SetMaxDeltaTime_External(float InMaxDeltaTime)
		{
			MMaxDeltaTime = InMaxDeltaTime;
		}

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Chaos/Public/Chaos/PhysicsSolverBaseImpl.h:48

Scope (from outer to inner):

file
namespace    Chaos
function     void FPhysicsSolverBase::PullPhysicsStateForEachDirtyProxy_External

Source code excerpt:


		FPullPhysicsData* LatestData = nullptr;
		if (IsUsingAsyncResults() && UseAsyncInterpolation)
		{
			SCOPE_CYCLE_COUNTER(STAT_AsyncInterpolateResults);

			const FReal ResultsTime = GetPhysicsResultsTime_External();
			//we want to interpolate between prev and next. There are a few cases to consider:
			//case 1: dirty data exists in both prev and next. In this case continuous data is interpolated, state data is a step function from prev to next