ClusterUnion.ApplyReplicatedRigidStateOnCreatePhysicsState
ClusterUnion.ApplyReplicatedRigidStateOnCreatePhysicsState
#Overview
name: ClusterUnion.ApplyReplicatedRigidStateOnCreatePhysicsState
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When physics state is created, apply replicated rigid state. Useful because sometimes the initial OnRep will have been called before a proxy exists, so initial properties will be unset
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of ClusterUnion.ApplyReplicatedRigidStateOnCreatePhysicsState is to control whether the replicated rigid state should be applied when the physics state is created for a ClusterUnionComponent. This setting is primarily used in the physics engine subsystem of Unreal Engine 5, specifically for the ClusterUnion functionality.
This setting variable is used in the Engine module, particularly in the PhysicsEngine subsystem. It’s referenced in the ClusterUnionComponent.cpp file, which suggests it’s closely tied to the ClusterUnionComponent’s functionality.
The value of this variable is set using an FAutoConsoleVariableRef, which means it can be adjusted at runtime through console commands. By default, it’s set to true.
This variable interacts directly with the associated boolean variable bApplyReplicatedRigidStateOnCreatePhysicsState. They share the same value, and the console variable serves as a way to modify this setting dynamically.
Developers must be aware that this variable affects the behavior of the ClusterUnionComponent when its physics state is created. When set to true, it ensures that the replicated rigid state is applied even if the initial OnRep call occurred before the physics proxy was created.
Best practices when using this variable include:
- Consider the networking implications, as this setting is designed to handle scenarios where network replication and physics state creation may not be perfectly synchronized.
- Monitor performance impacts, as applying the replicated state on physics state creation could introduce additional processing.
- Use this setting in conjunction with other ClusterUnion settings to fine-tune the behavior of physics replication in networked environments.
Regarding the associated variable bApplyReplicatedRigidStateOnCreatePhysicsState:
The purpose of bApplyReplicatedRigidStateOnCreatePhysicsState is to serve as the actual boolean flag that controls the behavior within the ClusterUnionComponent’s code.
This variable is used directly in the UClusterUnionComponent::OnCreatePhysicsState function to determine whether to call OnRep_RigidState() when the physics state is created.
The value of this variable is set by the console variable we discussed earlier, allowing for runtime adjustment.
It interacts with the OnRep_RigidState() function of the ClusterUnionComponent, potentially affecting how replicated physics data is applied.
Developers should be aware that this variable directly impacts the initialization of the ClusterUnionComponent’s physics state, particularly in networked scenarios.
Best practices include:
- Ensure that any code relying on the initial physics state is aware of this setting, as it may affect when certain properties are fully initialized.
- Consider logging or debugging the state of this variable when troubleshooting physics replication issues in ClusterUnionComponents.
- Test thoroughly with this setting both enabled and disabled to ensure proper behavior in various networking scenarios.
#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:36
Scope (from outer to inner):
file
namespace anonymous
Source code excerpt:
bool bApplyReplicatedRigidStateOnCreatePhysicsState = true;
FAutoConsoleVariableRef CVarApplyReplicatedRigidStateOnCreatePhysicsState(TEXT("ClusterUnion.ApplyReplicatedRigidStateOnCreatePhysicsState"), bApplyReplicatedRigidStateOnCreatePhysicsState, TEXT("When physics state is created, apply replicated rigid state. Useful because sometimes the initial OnRep will have been called before a proxy exists, so initial properties will be unset"));
bool bDirtyRigidStateOnlyIfChanged = false;
FAutoConsoleVariableRef CVarDirtyRigidStateOnlyIfChanged(TEXT("ClusterUnion.DirtyRigidStateOnlyIfChanged"), bDirtyRigidStateOnlyIfChanged, TEXT("Add a check for changed rigid state before marking it dirty and updating the replicated data. No need to flush an update if there was no change."));
bool bFlushNetDormancyOnSyncProxy = true;
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."));
#Associated Variable and Callsites
This variable is associated with another variable named bApplyReplicatedRigidStateOnCreatePhysicsState
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ClusterUnionComponent.cpp:35
Scope (from outer to inner):
file
namespace anonymous
Source code excerpt:
FAutoConsoleVariableRef CVarLocalBoneDataMapGrowFactor(TEXT("ClusterUnion.LocalBoneDataMapGrowFactor"), LocalBoneDataMapGrowFactor, TEXT("Grow factor to apply to the size of bone data array of pre-existing component when preallocating the local bones data map"));
bool bApplyReplicatedRigidStateOnCreatePhysicsState = true;
FAutoConsoleVariableRef CVarApplyReplicatedRigidStateOnCreatePhysicsState(TEXT("ClusterUnion.ApplyReplicatedRigidStateOnCreatePhysicsState"), bApplyReplicatedRigidStateOnCreatePhysicsState, TEXT("When physics state is created, apply replicated rigid state. Useful because sometimes the initial OnRep will have been called before a proxy exists, so initial properties will be unset"));
bool bDirtyRigidStateOnlyIfChanged = false;
FAutoConsoleVariableRef CVarDirtyRigidStateOnlyIfChanged(TEXT("ClusterUnion.DirtyRigidStateOnlyIfChanged"), bDirtyRigidStateOnlyIfChanged, TEXT("Add a check for changed rigid state before marking it dirty and updating the replicated data. No need to flush an update if there was no change."));
bool bFlushNetDormancyOnSyncProxy = true;
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."));
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/PhysicsEngine/ClusterUnionComponent.cpp:758
Scope (from outer to inner):
file
function void UClusterUnionComponent::OnCreatePhysicsState
Source code excerpt:
// Since the initial OnRep_RigidState might've occurred before we actually had a physics state,
// do OnRep actions again now to make sure we start off with the right data.
if (bApplyReplicatedRigidStateOnCreatePhysicsState)
{
OnRep_RigidState();
}
}
}