UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PushModel.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "PushModelMacros.h"
6
7#if WITH_PUSH_MODEL
8
9#include "CoreMinimal.h"
10#include "Delegates/Delegate.h"
11#include "UObject/ObjectKey.h"
12
124#if 0
125USTRUCT()
127{
128 UPROPERTY()
130
131 UPROPERTY()
133}
134
135UCLASS()
137{
139
140
142 {
145 }
146
152 UFUNCTION(BlueprintCallable)
153 void SetMyBlueprintProperty(const int32 NewValue)
154 {
155 MyBlueprintProperty = NewValue;
157 }
158
163 void MySetter(const FString& NewValue)
164 {
165 MyBlueprintSetterProperty = NewValue;
167 }
168
170 void SetStaticArrayValue(const int32 NewValue, const int32 Index)
171 {
172 MyStaticArray[Index] = NewValue;
174 }
175
176 void SetEntireStaticArray(const int32 NewArray[4])
177 {
180 }
181
187 void UpdateMyStruct(int32 NewValue)
188 {
189 MyStruct.SomeReplicatedProperty = NewValue;
191 }
192
193 void UpdateMyStruct(bool bNewValue)
194 {
195 MyStruct.bSomeOtherReplicatedProperty = bNewValue;
197 }
198
216 {
218 return MyStruct;
219 }
220
221 virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override
222 {
223 Super::GetLifetimeReplicatedProps(OutLifetimeProps);
224
226
227 Params.bIsPushBased = true;
233
234 Params.bIsPushBased = false;
236 }
237
238private:
239
243
250 UPROPERTY(Replicated, BlueprintReadWrite, Meta=(AllowPrivateAccess="true"))
252
257 UPROPERTY(Replicated, BlueprintSetter=SetMyBlueprintSetterProperty, Meta = (AllowPrivateAccess = "true"))
259
262
269
272};
273#endif
274
275// DO NOT USE METHODS IN THIS NAMESPACE DIRECTLY
276// Use the Macros instead, as they respect conditional compilation.
277// See PushModelMarcos.h
278namespace UEPushModelPrivate
279{
280 //~ Using int32 isn't very forward looking, but for now GUObjectArray also uses int32
281 //~ so we're probably safe.
282
286
287 // The ID need to be able to handle both Iris and non-Iris replication.
288 struct FNetPushObjectId
289 {
290 FNetPushObjectId() : Value(0xFFFFFFFFFFFFFFFFULL) {}
291 explicit FNetPushObjectId(FNetLegacyPushObjectId Id) { Value = 0xFFFFFFFF00000000ULL | uint32(Id); }
293
294 bool IsValid() const { return Value != 0xFFFFFFFFFFFFFFFFULL; }
295 bool IsIrisId() const { return uint32(Value >> 32U) != 0xFFFFFFFFU; }
296 uint64 GetValue() const { return Value; }
297
300
301 private:
303 };
304
307 {
311 {
312 // They should either both be valid, or both invalid.
314 }
315
321
324
325 const bool IsValid() const
326 {
327 return INDEX_NONE != ObjectId;
328 }
329
331 {
333 }
334 };
335
338
340 static const bool IsPushModelEnabled()
341 {
342 return bIsPushModelEnabled;
343 }
344
346 static const bool MakeBpPropertiesPushModel()
347 {
349 }
350
353
356
357 static FString ToString(const FNetPushObjectId Id)
358 {
359 return FString::Printf(TEXT("0x%" UINT64_X_FMT), Id.GetValue());
360 }
361
378 NETCORE_API void MarkPropertyDirty(const UObject* Object, const FNetPushObjectId ObjectId, const int32 RepIndex);
379
395 NETCORE_API void MarkPropertyDirty(const UObject* Object, const FNetPushObjectId ObjectId, const int32 StartRepIndex, const int32 EndRepIndex);
396
397 //~ As the comments above state, none of the methods in this namespace should be invoked directly.
398 //~ Particularly, the methods below are **only** needed by internal systems.
399 //~ When Push Model is enabled, registration is handled automatically by the networking system, so no
400 //~ extra dev work is required.
401
404
406
408
410
411 NETCORE_API void LogMemory(FOutputDevice& Ar);
412
413 // For internal use only.
414 DECLARE_DELEGATE_ThreeParams(FIrisMarkPropertyDirty, const UObject*, UEPushModelPrivate::FNetIrisPushObjectId, const int32);
415 DECLARE_DELEGATE_FourParams(FIrisMarkPropertiesDirty, const UObject*, UEPushModelPrivate::FNetIrisPushObjectId, const int32, const int32);
416
419}
420
421
422#define CONDITIONAL_ON_PUSH_MODEL(Work) if (UEPushModelPrivate::IsPushModelEnabled()) { Work; }
423#define IS_PUSH_MODEL_ENABLED() UEPushModelPrivate::IsPushModelEnabled()
424#define PUSH_MAKE_BP_PROPERTIES_PUSH_MODEL() (UEPushModelPrivate::IsPushModelEnabled() && UEPushModelPrivate::MakeBpPropertiesPushModel())
425
426#define GET_PROPERTY_REP_INDEX(ClassName, PropertyName) (int32)ClassName::ENetFields_Private::PropertyName
427#define GET_PROPERTY_REP_INDEX_STATIC_ARRAY_START(ClassName, PropertyName) ((int32)ClassName::ENetFields_Private::PropertyName ## _STATIC_ARRAY)
428#define GET_PROPERTY_REP_INDEX_STATIC_ARRAY_END(ClassName, PropertyName) ((int32)ClassName::ENetFields_Private::PropertyName ## _STATIC_ARRAY_END)
429#define GET_PROPERTY_REP_INDEX_STATIC_ARRAY_INDEX(ClassName, PropertyName, ArrayIndex) (GET_PROPERTY_REP_INDEX_STATIC_ARRAY_START(ClassName, PropertyName) + ArrayIndex)
430
431#define IS_PROPERTY_REPLICATED(Property) (0 != (EPropertyFlags::CPF_Net & Property->PropertyFlags))
432
433#define CONDITIONAL_ON_OBJECT_NET_ID(Object, Work) { const UEPushModelPrivate::FNetPushObjectId PrivatePushId(Object->GetNetPushId()); Work; }
434#define CONDITIONAL_ON_OBJECT_NET_ID_DYNAMIC(Object, Work) { const UEPushModelPrivate::FNetPushObjectId PrivatePushId(Object->GetNetPushIdDynamic()); Work; }
435#define CONDITIONAL_ON_REP_INDEX_AND_OBJECT_NET_ID(Object, Property, Work) if (IS_PROPERTY_REPLICATED(Property)) { const UEPushModelPrivate::FNetPushObjectId PrivatePushId(Object->GetNetPushIdDynamic()); Work; }
436
437//~ For these macros, we won't bother checking if Push Model is enabled. Instead, we'll just check to see whether or not the Custom ID is valid.
438
439// Marks a property dirty by RepIndex without doing additional rep index validation.
440#define MARK_PROPERTY_DIRTY_UNSAFE(Object, RepIndex) CONDITIONAL_ON_OBJECT_NET_ID_DYNAMIC(Object, UEPushModelPrivate::MarkPropertyDirty(Object, PrivatePushId, RepIndex))
441
442// Marks a property dirty by UProperty*, validating that it's actually a replicated property.
443#define MARK_PROPERTY_DIRTY(Object, Property) CONDITIONAL_ON_REP_INDEX_AND_OBJECT_NET_ID(Object, Property, UEPushModelPrivate::MarkPropertyDirty(Object, PrivatePushId, Property->RepIndex))
444
445
446// Marks a static array property dirty given, the Object, UProperty*, and Index.
447#define MARK_PROPERTY_DIRTY_STATIC_ARRAY_INDEX(Object, Property, ArrayIndex) CONDITIONAL_ON_REP_INDEX_AND_OBJECT_NET_ID(Object, Property, UEPushModelPrivate::MarkPropertyDirty(Object, PrivatePushId, Property->RepIndex + ArrayIndex))
448
449// Marks all elements of a static array property dirty, given the Object and UProperty*
450#define MARK_PROPERTY_DIRTY_STATIC_ARRAY(Object, Property) CONDITIONAL_ON_REP_INDEX_AND_OBJECT_NET_ID(Object, Property, UEPushModelPrivate::MarkPropertyDirty(Object, PrivatePushId, Property->RepIndex, Property->RepIndex + Property->ArrayDim - 1))
451
452
453// Marks a property dirty, given the Class Name, Property Name, and Object. This will fail to compile if the Property or Class aren't valid.
454#define MARK_PROPERTY_DIRTY_FROM_NAME(ClassName, PropertyName, Object) CONDITIONAL_ON_OBJECT_NET_ID(Object, UEPushModelPrivate::MarkPropertyDirty(Object, PrivatePushId, GET_PROPERTY_REP_INDEX(ClassName, PropertyName)))
455
456// Marks a static array property dirty, given the Class Name, Property Name, Index, and Object. This will fail to compile if the Property and Class aren't valid. Callers are responsible for validating the index.
457#define MARK_PROPERTY_DIRTY_FROM_NAME_STATIC_ARRAY_INDEX(ClassName, PropertyName, ArrayIndex, Object) CONDITIONAL_ON_OBJECT_NET_ID(Object, UEPushModelPrivate::MarkPropertyDirty(Object, PrivatePushId, GET_PROPERTY_REP_INDEX_STATIC_ARRAY_INDEX(ClassName, PropertyName, ArrayIndex)))
458
459// Marks an entire static array property dirty, given the Class Name, Property Name, and Object. This will fail to compile if the Property or Class aren't valid.
460#define MARK_PROPERTY_DIRTY_FROM_NAME_STATIC_ARRAY(ClassName, PropertyName, Object) CONDITIONAL_ON_OBJECT_NET_ID(Object, UEPushModelPrivate::MarkPropertyDirty(Object, PrivatePushId, GET_PROPERTY_REP_INDEX_STATIC_ARRAY_START(ClassName, PropertyName), GET_PROPERTY_REP_INDEX_STATIC_ARRAY_END(ClassName, PropertyName)))
461
466#define COMPARE_ASSIGN_AND_MARK_PROPERTY_DIRTY(ClassName, PropertyName, NewValue, Object) \
467 if (NewValue != PropertyName) { PropertyName = NewValue; MARK_PROPERTY_DIRTY_FROM_NAME(ClassName, PropertyName, Object); }
468
469#define UE_NET_SET_IRIS_MARK_PROPERTY_DIRTY_DELEGATE(Delegate) UEPushModelPrivate::SetIrisMarkPropertyDirtyDelegate(Delegate)
470#define UE_NET_SET_IRIS_MARK_PROPERTIES_DIRTY_DELEGATE(Delegate) UEPushModelPrivate::SetIrisMarkPropertiesDirtyDelegate(Delegate)
471
472#else // WITH_PUSH_MODEL
473
474#define MARK_PROPERTY_DIRTY_UNSAFE(Object, RepIndex)
475#define MARK_PROPERTY_DIRTY(Object, Property)
476#define MARK_PROPERTY_DIRTY_STATIC_ARRAY_INDEX(Object, RepIndex, ArrayIndex)
477#define MARK_PROPERTY_DIRTY_STATIC_ARRAY(Object, RepIndex, ArrayIndex)
478
479#define MARK_PROPERTY_DIRTY_FROM_NAME(ClassName, PropertyName, Object)
480#define MARK_PROPERTY_DIRTY_FROM_NAME_STATIC_ARRAY_INDEX(ClassName, PropertyName, ArrayIndex, Object)
481#define MARK_PROPERTY_DIRTY_FROM_NAME_STATIC_ARRAY(ClassName, PropertyName, ArrayIndex, Object)
482
483
484#define GET_PROPERTY_REP_INDEX(ClassName, PropertyName) INDEX_NONE
485#define GET_PROPERTY_REP_INDEX_STATIC_ARRAY(ClassName, PropertyName, ArrayIndex) INDEX_NONE
486
487#define IS_PUSH_MODEL_ENABLED() false
488#define PUSH_MAKE_BP_PROPERTIES_PUSH_MODEL() false
489
490#define COMPARE_ASSIGN_AND_MARK_PROPERTY_DIRTY(ClassName, PropertyName, NewValue, Object) \
491 if (NewValue != PropertyName) { PropertyName = NewValue; }
492
493#define UE_NET_SET_IRIS_MARK_PROPERTY_DIRTY_DELEGATE(...)
494#define UE_NET_SET_IRIS_MARK_PROPERTIES_DIRTY_DELEGATE(...)
495
496#endif
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
#define UINT64_X_FMT
Definition AndroidPlatformString.h:70
#define check(expr)
Definition AssertionMacros.h:314
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_DELEGATE_ThreeParams(DelegateName, Param1Type, Param2Type, Param3Type)
Definition DelegateCombinations.h:66
#define DECLARE_DELEGATE_FourParams(DelegateName, Param1Type, Param2Type, Param3Type, Param4Type)
Definition DelegateCombinations.h:75
return true
Definition ExternalRpcRegistry.cpp:601
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define UCLASS(...)
Definition ObjectMacros.h:776
#define USTRUCT(...)
Definition ObjectMacros.h:746
#define MARK_PROPERTY_DIRTY_FROM_NAME(ClassName, PropertyName, Object)
Definition PushModel.h:479
#define MARK_PROPERTY_DIRTY_FROM_NAME_STATIC_ARRAY_INDEX(ClassName, PropertyName, ArrayIndex, Object)
Definition PushModel.h:480
#define MARK_PROPERTY_DIRTY_FROM_NAME_STATIC_ARRAY(ClassName, PropertyName, ArrayIndex, Object)
Definition PushModel.h:481
#define DOREPLIFETIME_WITH_PARAMS_FAST(c, v, params)
Definition UnrealNetwork.h:231
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Actor.h:257
Definition OutputDevice.h:133
Definition Array.h:670
Definition Object.h:95
T::FDataType GetValue(const UBlackboardComponent &Blackboard, const FName &Name, FBlackboard::FKey &InOutCachedKey, const typename T::FDataType &DefaultValue)
Definition ValueOrBBKey.h:51
FString ToString(uint16 Value)
Definition PathFollowingComponent.cpp:82
FUniformParams Params
Definition MeshPaintVirtualTexture.cpp:162
Definition RepLayout.cpp:129
UEPushModelPrivate::FPushModelPerNetDriverState * GetPerNetDriverState(const FRepChangelistState *ChangelistState)
Definition RepLayout.cpp:249
U16 Index
Definition radfft.cpp:71
Definition UnrealNetwork.h:135
Definition ObjectKey.h:19