p.Chaos.CU.UseFlushNetDormancy

p.Chaos.CU.UseFlushNetDormancy

#Overview

name: p.Chaos.CU.UseFlushNetDormancy

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 p.Chaos.CU.UseFlushNetDormancy is to control the behavior of network dormancy flushing for cluster unions in the Chaos physics system of Unreal Engine 5.

This setting variable is primarily used in the physics engine subsystem, specifically in the Chaos physics implementation. It is referenced in the ClusterUnionReplicatedProxyComponent, which is part of the Engine module.

The value of this variable is set using an FAutoConsoleVariableRef, which means it can be modified at runtime through console commands. By default, it is set to true.

The associated variable ClusterUnionUseFlushNetDormancy directly interacts with p.Chaos.CU.UseFlushNetDormancy. They share the same value and are used interchangeably in the code.

Developers must be aware that when this variable is set to true, it will flush the net dormancy of the owner actor in the next frame instead of waking up the actor. This can have implications for network performance and behavior of replicated actors in a multiplayer game.

Best practices when using this variable include:

  1. Consider the impact on network performance when enabling or disabling this feature.
  2. Test thoroughly in multiplayer scenarios to ensure desired behavior.
  3. Use it in conjunction with other network optimizations to achieve the best balance between performance and gameplay fidelity.

Regarding the associated variable ClusterUnionUseFlushNetDormancy:

The purpose of ClusterUnionUseFlushNetDormancy is to provide a local, easily accessible boolean flag that reflects the value of p.Chaos.CU.UseFlushNetDormancy.

This variable is used within the Engine module, specifically in the ClusterUnionReplicatedProxyComponent.

The value of this variable is set initially to true and can be modified through the console variable p.Chaos.CU.UseFlushNetDormancy.

It directly interacts with p.Chaos.CU.UseFlushNetDormancy and is used in the FlushNetDormancyIfNeeded function to determine whether to proceed with flushing net dormancy.

Developers should be aware that this variable controls the behavior of the FlushNetDormancyIfNeeded function. When false, the function will return early without performing any actions.

Best practices for using this variable include:

  1. Ensure consistency between this variable and p.Chaos.CU.UseFlushNetDormancy.
  2. Consider the performance implications of frequent changes to this variable during runtime.
  3. Use it as a quick way to toggle the net dormancy flushing behavior in debug scenarios or performance testing.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ClusterUnionReplicatedProxyComponent.cpp:13

Scope (from outer to inner):

file
namespace    ClusterUnionCVars

Source code excerpt:

{
	bool ClusterUnionUseFlushNetDormancy = true;
	FAutoConsoleVariableRef CVarClusterUnionUseFlushNetDormancy(TEXT("p.Chaos.CU.UseFlushNetDormancy"), ClusterUnionUseFlushNetDormancy, TEXT("When true it will flush the net dormancy of the owner the next frame instead of awaking the actor"));
}

UClusterUnionReplicatedProxyComponent::UClusterUnionReplicatedProxyComponent(const FObjectInitializer& ObjectInitializer)
	: UActorComponent(ObjectInitializer)
{
	SetIsReplicatedByDefault(true);

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ClusterUnionReplicatedProxyComponent.cpp:12

Scope (from outer to inner):

file
namespace    ClusterUnionCVars

Source code excerpt:

namespace ClusterUnionCVars
{
	bool ClusterUnionUseFlushNetDormancy = true;
	FAutoConsoleVariableRef CVarClusterUnionUseFlushNetDormancy(TEXT("p.Chaos.CU.UseFlushNetDormancy"), ClusterUnionUseFlushNetDormancy, TEXT("When true it will flush the net dormancy of the owner the next frame instead of awaking the actor"));
}

UClusterUnionReplicatedProxyComponent::UClusterUnionReplicatedProxyComponent(const FObjectInitializer& ObjectInitializer)
	: UActorComponent(ObjectInitializer)
{
	SetIsReplicatedByDefault(true);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ClusterUnionReplicatedProxyComponent.cpp:188

Scope (from outer to inner):

file
function     void UClusterUnionReplicatedProxyComponent::FlushNetDormancyIfNeeded

Source code excerpt:

void UClusterUnionReplicatedProxyComponent::FlushNetDormancyIfNeeded()
{
	if (!ClusterUnionCVars::ClusterUnionUseFlushNetDormancy)
	{
		return;
	}

	if (AActor* Owner = GetOwner())
	{