UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE::Net::Private::FReplicationPrioritization Class Reference

#include <ReplicationPrioritization.h>

Classes

class  FPrioritizerBatchHelper
 
class  FUpdateDirtyObjectsBatchHelper
 

Public Member Functions

 FReplicationPrioritization ()
 
void Init (FReplicationPrioritizationInitParams &Params)
 
void Deinit ()
 
void OnMaxInternalNetRefIndexIncreased (FInternalNetRefIndex NewMaxInternalIndex)
 
void Prioritize (const FNetBitArrayView &ConnectionsToSend, const FNetBitArrayView &DirtyObjectsThisFrame)
 
void SetStaticPriority (uint32 ObjectIndex, float Prio)
 
bool SetPrioritizer (uint32 ObjectIndex, FNetObjectPrioritizerHandle Prioritizer)
 
FNetObjectPrioritizerHandle GetPrioritizerHandle (const FName PrioritizerName) const
 
UNetObjectPrioritizerGetPrioritizer (const FName PrioritizerName) const
 
void AddConnection (uint32 ConnectionId)
 
void RemoveConnection (uint32 ConnectionId)
 
float GetObjectPriorityForConnection (uint32 ConnectionId, FInternalNetRefIndex InternalIndex) const
 

Constructor & Destructor Documentation

◆ FReplicationPrioritization()

UE::Net::Private::FReplicationPrioritization::FReplicationPrioritization ( )

Member Function Documentation

◆ AddConnection()

void UE::Net::Private::FReplicationPrioritization::AddConnection ( uint32  ConnectionId)

◆ Deinit()

void UE::Net::Private::FReplicationPrioritization::Deinit ( )

◆ GetObjectPriorityForConnection()

float UE::Net::Private::FReplicationPrioritization::GetObjectPriorityForConnection ( uint32  ConnectionId,
FInternalNetRefIndex  InternalIndex 
) const
inline

◆ GetPrioritizer()

UNetObjectPrioritizer * UE::Net::Private::FReplicationPrioritization::GetPrioritizer ( const FName  PrioritizerName) const

◆ GetPrioritizerHandle()

FNetObjectPrioritizerHandle UE::Net::Private::FReplicationPrioritization::GetPrioritizerHandle ( const FName  PrioritizerName) const

◆ Init()

void UE::Net::Private::FReplicationPrioritization::Init ( FReplicationPrioritizationInitParams Params)

◆ OnMaxInternalNetRefIndexIncreased()

void UE::Net::Private::FReplicationPrioritization::OnMaxInternalNetRefIndexIncreased ( FInternalNetRefIndex  NewMaxInternalIndex)

Called when the maximum InternalNetRefIndex increased and we need to realloc our lists

◆ Prioritize()

void UE::Net::Private::FReplicationPrioritization::Prioritize ( const FNetBitArrayView ReplicatingConnections,
const FNetBitArrayView DirtyObjectsThisFrame 
)

There are many different ways to determine which objects should be prioritized. They have different performance characteristics. Here are some ways:

  • Prioritize all objects that have been marked as dirty this frame along with each connection's wishes due to packet loss. packet loss should be rare and the list of objects with lost state should be small. This way works well if the number of dirty objects is relatively small. This should save a lot of time on the setup of the prioritization data. This can be coupled with having lost objects get a priority bump every frame until it's been resent. The latter would mean that there's no extra per connection setup cost at all other than filling in the right pointer to the priority data. A similar approach can also be taken with throttling of how often connections are replicated to. For example if a third of all connections are considered each net tick then one would maintain three different dirty object structures.
  • Get the list of objects to prioritize from each connection. This can make sense if there are many connections and they have very different sets of scoped objects, for example if spatial filtering is applied and players are far away from eachother. Prioritizing all connections' relevant objects would then cause ConnectionCount*PerConnectionObjectCount to be prioritized per connection which could be very expensive.

If performance issues arise in certain scenarios like initial world spawn or late joing here are some additional thoughts.

During world spawn or late join it's likely a connection wants to replicate many objects. This can stress this system if there are a lot of objects using dynamic prioritization. Perhaps having the ReplicationDataStream in a special state where many (or special) objects are replicated first before starting prioritizing dirty objects as well is something to consider. One could also just consider a smaller amount of objects (say 200) each frame and continue from the last object index prioritized the next time we get here. This works not only at initial replication but also if there is often a very large amount of dynamically prioritized objects. The connection will get the last priority value for the objects that aren't prioritized this frame. A very simple yet effective optimization! There can of course be artifacts such as an object receiving a low priority and then the player rotates quickly so that object is in the line of sight and it doesn't get replicated for a few fames until it receives the high priority it should have had. Perhaps one could mark either certain objects as not being subject to priority calculation throttling or mark a prioritizer as not being subject to throttling, in which case all dirty objects with such a prioritizer would always get an updated priority. Prioritize objects as per connection's wishes.

◆ RemoveConnection()

void UE::Net::Private::FReplicationPrioritization::RemoveConnection ( uint32  ConnectionId)

◆ SetPrioritizer()

bool UE::Net::Private::FReplicationPrioritization::SetPrioritizer ( uint32  ObjectIndex,
FNetObjectPrioritizerHandle  Prioritizer 
)

Not marking this object as in need of copying a new priority to each connection. We keep the old priority value regardless of which prioritizer was previously used. That should work ok when we're throttling priority calculations. Let's just set the new default priority.

◆ SetStaticPriority()

void UE::Net::Private::FReplicationPrioritization::SetStaticPriority ( uint32  ObjectIndex,
float  Prio 
)

The documentation for this class was generated from the following files: