ClusterUnion.SkipZeroStateInOnRep

ClusterUnion.SkipZeroStateInOnRep

#Overview

name: ClusterUnion.SkipZeroStateInOnRep

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 ClusterUnion.SkipZeroStateInOnRep is to control whether uninitialized states (represented by 0) should be skipped when running the OnRep function for the replicated rigid state of the cluster union in Unreal Engine 5’s physics system.

This setting variable is primarily used in the Physics Engine subsystem, specifically within the Cluster Union component. It is part of the Engine module and affects the replication behavior of rigid states in networked environments.

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

The associated variable GSkipZeroStateInOnRep directly interacts with ClusterUnion.SkipZeroStateInOnRep. They share the same value and are used interchangeably in the code.

Developers must be aware that this variable affects network replication behavior. When set to true, it prevents the OnRep function from processing uninitialized states, which can optimize network performance by reducing unnecessary updates.

Best practices when using this variable include:

  1. Consider the impact on network performance and gameplay when modifying its value.
  2. Use it in conjunction with other networking optimizations to achieve the best balance between performance and accuracy.
  3. Test thoroughly in networked environments to ensure desired behavior across different network conditions.

Regarding the associated variable GSkipZeroStateInOnRep:

The purpose of GSkipZeroStateInOnRep is identical to ClusterUnion.SkipZeroStateInOnRep, as they share the same value and functionality.

It is used directly in the OnRep_RigidState function of the UClusterUnionComponent class to determine whether to skip processing when the replicated rigid state is uninitialized (ObjectState == 0).

The value of GSkipZeroStateInOnRep is set at the same time as ClusterUnion.SkipZeroStateInOnRep through the FAutoConsoleVariableRef.

Developers should be aware that modifying GSkipZeroStateInOnRep will have the same effect as modifying ClusterUnion.SkipZeroStateInOnRep. It’s important to maintain consistency when working with these variables.

Best practices for GSkipZeroStateInOnRep are the same as those for ClusterUnion.SkipZeroStateInOnRep, as they are essentially the same variable used in different contexts within the code.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ClusterUnionComponent.cpp:45

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:


	bool GSkipZeroStateInOnRep = true;
	FAutoConsoleVariableRef CVarSkipZeroState(TEXT("ClusterUnion.SkipZeroStateInOnRep"), GSkipZeroStateInOnRep, TEXT("Whether we skip 0 (uninitialized) states when running the onrep for the replicated rigid state of the cluster union"));

	template<typename PayloadType>
	struct TClusterUnionAABBTreeStorageTraits
	{
		constexpr static uint32 HashTableBucketsSize = 256;

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ClusterUnionComponent.cpp:44

Scope (from outer to inner):

file
namespace    anonymous

Source code excerpt:

	FAutoConsoleVariableRef CVarFlushNetDormancyOnSyncProxy(TEXT("ClusterUnion.FlushNetDormancyOnSyncProxy"), bFlushNetDormancyOnSyncProxy, TEXT("When there is a new rigid state on the authority, flush net dormancy so that even if this object is net dorman the rigid state will come through to the client."));

	bool GSkipZeroStateInOnRep = true;
	FAutoConsoleVariableRef CVarSkipZeroState(TEXT("ClusterUnion.SkipZeroStateInOnRep"), GSkipZeroStateInOnRep, TEXT("Whether we skip 0 (uninitialized) states when running the onrep for the replicated rigid state of the cluster union"));

	template<typename PayloadType>
	struct TClusterUnionAABBTreeStorageTraits
	{
		constexpr static uint32 HashTableBucketsSize = 256;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ClusterUnionComponent.cpp:1327

Scope (from outer to inner):

file
function     void UClusterUnionComponent::OnRep_RigidState

Source code excerpt:

	// the server (we call this onrep in OnCreatePhysicsState too incase we got a
	// new state but didn't have a proxy at that time)
	if (!PhysicsProxy || (ReplicatedRigidState.ObjectState == 0 && GSkipZeroStateInOnRep))
	{
		return;
	}

	PhysicsProxy->SetIsAnchored_External(ReplicatedRigidState.bIsAnchored);
	SetRigidState(static_cast<Chaos::EObjectStateType>(ReplicatedRigidState.ObjectState));