-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNetworkPhysicsComponentNetSerializers.cpp
More file actions
2266 lines (1964 loc) · 89 KB
/
Copy pathNetworkPhysicsComponentNetSerializers.cpp
File metadata and controls
2266 lines (1964 loc) · 89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright Epic Games, Inc. All Rights Reserved.
#include "Physics/NetworkPhysicsComponentNetSerializers.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(NetworkPhysicsComponentNetSerializers)
#include "Iris/ReplicationState/PropertyNetSerializerInfoRegistry.h"
#include "Iris/ReplicationState/ReplicationStateDescriptorBuilder.h"
#include "Iris/Serialization/NetBitStreamReader.h"
#include "Iris/Serialization/NetBitStreamUtil.h"
#include "Iris/Serialization/NetBitStreamWriter.h"
#include "Iris/Serialization/NetSerializerArrayStorage.h"
#include "Iris/Serialization/NetSerializerDelegates.h"
#include "Iris/Serialization/NetSerializers.h"
#include "Iris/Serialization/PackedIntNetSerializers.h"
#include "Misc/ScopeExit.h"
#include "Misc/ScopeRWLock.h"
#include "Net/Core/Trace/NetTrace.h"
#include "Physics/NetworkPhysicsComponent.h"
#include "Templates/IsPODType.h"
#include "UObject/UObjectIterator.h"
// Forward declarations so TIsPODType can be specialized before FNetSerializerArrayStorage<T> is instantiated.
namespace UE::Net
{
struct FNetworkPhysicsActionElementQuantized;
struct FNetworkPhysicsElementQuantized;
struct FNetworkPhysicsPayloadQuantized;
struct FNetworkPhysicsActionPayloadQuantized;
struct FNetworkPhysicsDataCollectionQuantized;
struct FNetworkPhysicsActionCollectionQuantized;
}
// ---- POD (Plain Old Data) declarations (required by FNetSerializerArrayStorage) ----------------
template<> struct TIsPODType<UE::Net::FNetworkPhysicsActionElementQuantized> { enum { Value = true }; };
template<> struct TIsPODType<UE::Net::FNetworkPhysicsElementQuantized> { enum { Value = true }; };
template<> struct TIsPODType<UE::Net::FNetworkPhysicsPayloadQuantized> { enum { Value = true }; };
template<> struct TIsPODType<UE::Net::FNetworkPhysicsActionPayloadQuantized> { enum { Value = true }; };
template<> struct TIsPODType<UE::Net::FNetworkPhysicsDataCollectionQuantized> { enum { Value = true }; };
template<> struct TIsPODType<UE::Net::FNetworkPhysicsActionCollectionQuantized> { enum { Value = true }; };
namespace UE::Net
{
// ============================================================
// Internal quantized types
// ============================================================
// Per-element quantized data for a collection array element.
// StructData holds the quantized form of the concrete derived struct.
// StructName is the fully-qualified path name used to identify and look up the concrete type.
// StructDescriptorTraits is used to skip dynamic-state calls when the struct has none.
struct FNetworkPhysicsElementQuantized
{
FNetSerializerAlignedStorage StructData;
FName StructName;
EReplicationStateTraits StructDescriptorTraits;
};
// Per-element quantized data for an action collection element. Identical layout.
struct FNetworkPhysicsActionElementQuantized
{
FNetSerializerAlignedStorage StructData;
FName StructName;
EReplicationStateTraits StructDescriptorTraits;
};
// Payload base-struct quantized form: just the frame counter stored as ServerFrame+1 (unsigned).
// Zero-initialized state (QuantizedServerFrame==0) represents ServerFrame==-1 (INDEX_NONE).
struct FNetworkPhysicsPayloadQuantized
{
uint32 QuantizedServerFrame;
};
// Action payload base-struct quantized form: same frame encoding plus ActionId.
struct FNetworkPhysicsActionPayloadQuantized
{
uint32 QuantizedServerFrame;
uint32 SourceId;
uint16 ActionId;
};
// Quantized form for a full data collection.
struct FNetworkPhysicsDataCollectionQuantized
{
FNetSerializerArrayStorage<FNetworkPhysicsElementQuantized> Elements;
};
// Quantized form for a full action collection.
struct FNetworkPhysicsActionCollectionQuantized
{
FNetSerializerArrayStorage<FNetworkPhysicsActionElementQuantized> Elements;
};
} // namespace UE::Net
namespace UE::Net
{
// Forward-declared helpers - definitions are below with the collection serializers.
static void WritePackedUint32(FNetSerializationContext& Context, const FNetSerializeArgs& BaseArgs, uint32 Value);
static void WritePackedUint32(FNetSerializationContext& Context, const FNetSerializeDeltaArgs& BaseArgs, uint32 Value);
static uint32 ReadPackedUint32(FNetSerializationContext& Context, const FNetDeserializeArgs& BaseArgs);
static uint32 ReadPackedUint32(FNetSerializationContext& Context, const FNetDeserializeDeltaArgs& BaseArgs);
// ============================================================
// FNetworkPhysicsDescriptorCache
// ============================================================
// Caches replication state descriptors, struct type hashes, UScriptStruct* pointers, and custom serializer lookups.
// Replaces FInstancedStructDescriptorCache (IrisCore-internal, not exported) using the
// IRISCORE_API FReplicationStateDescriptorBuilder::CreateDescriptorForStruct.
// Thread-safe via FRWLock - reads are concurrent, writes are exclusive and rare (only on first encounter of a new type).
// Each collection serializer (DataCollection, ActionCollection) has its own static instance.
struct FNetworkPhysicsDescriptorCache
{
TRefCountPtr<const FReplicationStateDescriptor> FindDescriptor(FName StructPath) const
{
FReadScopeLock ReadLock(Lock);
const TRefCountPtr<const FReplicationStateDescriptor>* Found = Descriptors.Find(StructPath);
return Found ? *Found : TRefCountPtr<const FReplicationStateDescriptor>{};
}
TRefCountPtr<const FReplicationStateDescriptor> FindOrAddDescriptor(const UScriptStruct* Struct)
{
const FName PathFName(Struct->GetPathName());
{
FReadScopeLock ReadLock(Lock);
if (const TRefCountPtr<const FReplicationStateDescriptor>* Found = Descriptors.Find(PathFName))
{
return *Found;
}
}
// Build outside the lock - CreateDescriptorForStruct may perform UObject reflection work
TRefCountPtr<const FReplicationStateDescriptor> NewDescriptor =
FReplicationStateDescriptorBuilder::CreateDescriptorForStruct(Struct);
if (NewDescriptor.IsValid())
{
FWriteScopeLock WriteLock(Lock);
TRefCountPtr<const FReplicationStateDescriptor>& Slot = Descriptors.FindOrAdd(PathFName);
if (!Slot.IsValid())
{
Slot = NewDescriptor;
}
RegisterPath(PathFName, Struct);
return Slot;
}
return NewDescriptor;
}
TRefCountPtr<const FReplicationStateDescriptor> FindOrAddDescriptor(FName StructPath)
{
{
FReadScopeLock ReadLock(Lock);
if (const TRefCountPtr<const FReplicationStateDescriptor>* Found = Descriptors.Find(StructPath))
{
return *Found;
}
}
const UScriptStruct* Struct = FindOrCacheStruct(StructPath);
if (Struct)
{
return FindOrAddDescriptor(Struct);
}
return {};
}
// Deterministic 32-bit hash for a struct path name (goes on the wire, must be consistent across processes).
uint32 GetStructNameHash(FName StructPath)
{
{
FReadScopeLock ReadLock(Lock);
if (const uint32* Found = PathToHash.Find(StructPath))
{
return *Found;
}
}
const uint32 Hash = FCrc::StrCrc32(*StructPath.ToString());
FWriteScopeLock WriteLock(Lock);
PathToHash.Add(StructPath, Hash);
RegisterHash(Hash, StructPath);
return Hash;
}
// Resolve a 32-bit wire hash back to the FName path.
// On first miss, scans loaded subtypes of FNetworkPhysicsPayload/FNetworkPhysicsActionPayload to build the hash map
FName FindNameByHash(uint32 Hash)
{
{
FReadScopeLock ReadLock(Lock);
if (const FName* Found = HashToPath.Find(Hash))
{
return *Found;
}
}
if (!bDidFullScan)
{
// Build the scan results into a local map OUTSIDE the lock to avoid blocking readers
TMap<uint32, FName> ScannedHashes;
TMap<FName, const UScriptStruct*> ScannedStructs;
{
const UScriptStruct* PayloadBase = FNetworkPhysicsPayload::StaticStruct();
const UScriptStruct* ActionPayloadBase = FNetworkPhysicsActionPayload::StaticStruct();
for (TObjectIterator<UScriptStruct> It; It; ++It)
{
if (It->IsChildOf(PayloadBase) || It->IsChildOf(ActionPayloadBase))
{
const FName PathFName(It->GetPathName());
const uint32 StructHash = FCrc::StrCrc32(*PathFName.ToString());
ScannedHashes.Add(StructHash, PathFName);
ScannedStructs.Add(PathFName, *It);
}
}
}
// Merge scan results under a brief write lock
FWriteScopeLock WriteLock(Lock);
if (!bDidFullScan)
{
for (const TPair<uint32, FName>& Pair : ScannedHashes)
{
RegisterHash(Pair.Key, Pair.Value);
}
for (const TPair<FName, const UScriptStruct*>& Pair : ScannedStructs)
{
PathToHash.Add(Pair.Key, FCrc::StrCrc32(*Pair.Key.ToString()));
StructCache.Add(Pair.Key, Pair.Value);
}
bDidFullScan = true;
}
if (const FName* Found = HashToPath.Find(Hash))
{
return *Found;
}
}
return FName();
}
// Cached UScriptStruct* lookup - avoids repeated FindObject on hot paths.
const UScriptStruct* FindOrCacheStruct(FName StructPath)
{
{
FReadScopeLock ReadLock(Lock);
if (const UScriptStruct* const* Found = StructCache.Find(StructPath))
{
return *Found;
}
}
// FindObject happens outside the lock (UObject system is not lock-safe)
const UScriptStruct* Struct = FindObject<UScriptStruct>(nullptr, *StructPath.ToString());
if (Struct)
{
FWriteScopeLock WriteLock(Lock);
StructCache.Add(StructPath, Struct);
}
return Struct;
}
// Cached custom serializer lookup by path name - avoids per-element string ops.
// Returns nullptr if no custom serializer is registered (caller should use FStructNetSerializer).
const FNetSerializer* FindCustomSerializer(FName StructPath)
{
{
FReadScopeLock ReadLock(Lock);
if (const FNetSerializer* const* Found = CustomSerializerCache.Find(StructPath))
{
return *Found;
}
}
// Resolve outside the lock, then cache the result (including nullptr = "no custom serializer")
const FNetSerializer* Result = ResolveCustomSerializer(StructPath);
FWriteScopeLock WriteLock(Lock);
CustomSerializerCache.Add(StructPath, Result);
return Result;
}
// Cached UScriptStruct* -> path FName lookup - avoids per-element GetPathName FString alloc + FName construction.
// First call per type pays the same cost as today; all subsequent calls are a TMap hit.
FName GetCachedPathName(const UScriptStruct* Struct)
{
if (!Struct)
{
return FName();
}
{
FReadScopeLock ReadLock(Lock);
if (const FName* Found = PathNameByStruct.Find(Struct))
{
return *Found;
}
}
const FName PathFName(Struct->GetPathName());
FWriteScopeLock WriteLock(Lock);
// RegisterPath populates PathNameByStruct alongside HashToPath / PathToHash / StructCache.
RegisterPath(PathFName, Struct);
return PathFName;
}
private:
// Must be called under write lock
void RegisterPath(FName PathFName, const UScriptStruct* Struct)
{
const uint32 Hash = FCrc::StrCrc32(*PathFName.ToString());
RegisterHash(Hash, PathFName);
PathToHash.Add(PathFName, Hash);
StructCache.Add(PathFName, Struct);
PathNameByStruct.Add(Struct, PathFName);
}
// Must be called under write lock
void RegisterHash(uint32 Hash, FName PathFName)
{
if (const FName* Existing = HashToPath.Find(Hash))
{
ensureMsgf(*Existing == PathFName, TEXT("FNetworkPhysicsDescriptorCache: CRC32 hash collision between '%s' and '%s'"),
ToCStr(Existing->ToString()), ToCStr(PathFName.ToString()));
return; // Do not overwrite existing mapping on collision
}
HashToPath.Add(Hash, PathFName);
}
// Look up a custom serializer by full path name (e.g. "/Script/Engine.FNetworkPhysicsPayload").
// The registry expects the simple struct name (after the last dot), not the full path.
static const FNetSerializer* ResolveCustomSerializer(FName PathName)
{
if (PathName.IsNone())
{
return nullptr;
}
const FString PathStr = PathName.ToString();
int32 DotIdx = INDEX_NONE;
PathStr.FindLastChar(TEXT('.'), DotIdx);
const FName SimpleName = (DotIdx != INDEX_NONE) ? FName(PathStr.Mid(DotIdx + 1)) : PathName;
const FPropertyNetSerializerInfo* Info = FPropertyNetSerializerInfoRegistry::FindStructSerializerInfo(SimpleName);
return Info ? Info->GetNetSerializer(nullptr) : nullptr;
}
mutable FRWLock Lock;
TMap<FName, TRefCountPtr<const FReplicationStateDescriptor>> Descriptors;
TMap<uint32, FName> HashToPath;
TMap<FName, uint32> PathToHash;
TMap<FName, const UScriptStruct*> StructCache;
TMap<FName, const FNetSerializer*> CustomSerializerCache;
TMap<const UScriptStruct*, FName> PathNameByStruct;
bool bDidFullScan = false;
};
// ============================================================
// Shared collection helpers
// ============================================================
// Free per-element dynamic state then free the element's StructData storage.
template<typename ElementType>
static void FreeElement(FNetSerializationContext& Context, ElementType& Element, FNetworkPhysicsDescriptorCache& Cache)
{
if (Element.StructData.Num() > 0 && EnumHasAnyFlags(Element.StructDescriptorTraits, EReplicationStateTraits::HasDynamicState))
{
const FNetSerializer* CustomSerializer = Cache.FindCustomSerializer(Element.StructName);
if (CustomSerializer && EnumHasAnyFlags(CustomSerializer->Traits, ENetSerializerTraits::HasDynamicState))
{
FNetFreeDynamicStateArgs FreeArgs;
FreeArgs.NetSerializerConfig = CustomSerializer->DefaultConfig;
FreeArgs.Source = NetSerializerValuePointer(Element.StructData.GetData());
CustomSerializer->FreeDynamicState(Context, FreeArgs);
}
else if (!CustomSerializer)
{
FStructNetSerializerConfig StructConfig;
StructConfig.StateDescriptor = Cache.FindDescriptor(Element.StructName);
if (StructConfig.StateDescriptor.IsValid())
{
FNetFreeDynamicStateArgs FreeArgs;
FreeArgs.NetSerializerConfig = &StructConfig;
FreeArgs.Source = NetSerializerValuePointer(Element.StructData.GetData());
UE_NET_GET_SERIALIZER(FStructNetSerializer).FreeDynamicState(Context, FreeArgs);
}
}
}
Element.StructData.Free(Context);
}
// Write a struct type as a compact 32-bit CRC hash (deterministic across processes).
static void WriteStructNameHash(FNetBitStreamWriter& Writer, FName StructName, FNetworkPhysicsDescriptorCache& Cache)
{
Writer.WriteBits(Cache.GetStructNameHash(StructName), 32u);
}
// Read a 32-bit struct type hash and resolve to FName.
static FName ReadStructNameHash(FNetBitStreamReader& Reader, FNetworkPhysicsDescriptorCache& Cache)
{
const uint32 Hash = Reader.ReadBits(32u);
return Cache.FindNameByHash(Hash);
}
// Cached reference to the packed uint32 serializer - used by all count/frame write/read helpers.
static const FNetSerializer& GetPackedUint32Serializer()
{
return UE_NET_GET_SERIALIZER(FPackedUint32NetSerializer);
}
// Write a uint32 value using packed (variable-length) encoding.
static void WritePackedUint32(FNetSerializationContext& Context, const FNetSerializeArgs& BaseArgs, uint32 Value)
{
const FNetSerializer& PackedSerializer = GetPackedUint32Serializer();
FNetSerializeArgs PackedArgs = BaseArgs;
PackedArgs.Source = NetSerializerValuePointer(&Value);
PackedArgs.NetSerializerConfig = PackedSerializer.DefaultConfig;
PackedSerializer.Serialize(Context, PackedArgs);
}
// Overload accepting delta args (used by SerializeDelta functions).
static void WritePackedUint32(FNetSerializationContext& Context, const FNetSerializeDeltaArgs& BaseArgs, uint32 Value)
{
const FNetSerializer& PackedSerializer = GetPackedUint32Serializer();
FNetSerializeArgs PackedArgs;
PackedArgs.Version = BaseArgs.Version;
PackedArgs.Source = NetSerializerValuePointer(&Value);
PackedArgs.NetSerializerConfig = PackedSerializer.DefaultConfig;
PackedSerializer.Serialize(Context, PackedArgs);
}
// Read a uint32 value using packed (variable-length) encoding.
static uint32 ReadPackedUint32(FNetSerializationContext& Context, const FNetDeserializeArgs& BaseArgs)
{
const FNetSerializer& PackedSerializer = GetPackedUint32Serializer();
uint32 Value = 0u;
FNetDeserializeArgs PackedArgs = BaseArgs;
PackedArgs.Target = NetSerializerValuePointer(&Value);
PackedArgs.NetSerializerConfig = PackedSerializer.DefaultConfig;
PackedSerializer.Deserialize(Context, PackedArgs);
return Value;
}
// Overload accepting delta args (used by DeserializeDelta functions).
static uint32 ReadPackedUint32(FNetSerializationContext& Context, const FNetDeserializeDeltaArgs& BaseArgs)
{
const FNetSerializer& PackedSerializer = GetPackedUint32Serializer();
uint32 Value = 0u;
FNetDeserializeArgs PackedArgs;
PackedArgs.Version = BaseArgs.Version;
PackedArgs.Target = NetSerializerValuePointer(&Value);
PackedArgs.NetSerializerConfig = PackedSerializer.DefaultConfig;
PackedSerializer.Deserialize(Context, PackedArgs);
return Value;
}
// Templatized helpers shared by both DataCollection and ActionCollection serializers.
// Both element quantized types have identical layout (StructData, StructName, StructDescriptorTraits).
template<typename QuantizedCollectionType, typename ElementType>
static bool IsEqualImpl(const FNetIsEqualArgs& Args)
{
if (Args.bStateIsQuantized)
{
const QuantizedCollectionType& V0 = *reinterpret_cast<const QuantizedCollectionType*>(Args.Source0);
const QuantizedCollectionType& V1 = *reinterpret_cast<const QuantizedCollectionType*>(Args.Source1);
if (V0.Elements.Num() != V1.Elements.Num())
{
return false;
}
const ElementType* E0 = V0.Elements.GetData();
const ElementType* E1 = V1.Elements.GetData();
for (uint32 Idx = 0u; Idx < V0.Elements.Num(); ++Idx)
{
if (E0[Idx].StructName != E1[Idx].StructName)
{
return false;
}
if (E0[Idx].StructData.Num() != E1[Idx].StructData.Num())
{
return false;
}
if (FMemory::Memcmp(E0[Idx].StructData.GetData(), E1[Idx].StructData.GetData(), E0[Idx].StructData.Num()) != 0)
{
return false;
}
}
return true;
}
return false;
}
template<typename QuantizedCollectionType, typename ElementType>
static void CloneDynamicStateImpl(FNetSerializationContext& Context, const FNetCloneDynamicStateArgs& Args, FNetworkPhysicsDescriptorCache& Cache)
{
const QuantizedCollectionType& Source = *reinterpret_cast<const QuantizedCollectionType*>(Args.Source);
QuantizedCollectionType& Target = *reinterpret_cast<QuantizedCollectionType*>(Args.Target);
Target.Elements.Clone(Context, Source.Elements);
const ElementType* SrcElements = Source.Elements.GetData();
ElementType* DstElements = Target.Elements.GetData();
const uint32 Count = Source.Elements.Num();
for (uint32 Idx = 0u; Idx < Count; ++Idx)
{
DstElements[Idx].StructData.Clone(Context, SrcElements[Idx].StructData);
if (EnumHasAnyFlags(SrcElements[Idx].StructDescriptorTraits, EReplicationStateTraits::HasDynamicState))
{
// Dispatch to custom serializer if registered, otherwise FStructNetSerializer (mirrors FreeElement).
const FNetSerializer* CustomSerializer = Cache.FindCustomSerializer(SrcElements[Idx].StructName);
if (CustomSerializer && EnumHasAnyFlags(CustomSerializer->Traits, ENetSerializerTraits::HasDynamicState))
{
FNetCloneDynamicStateArgs CloneArgs = Args;
CloneArgs.NetSerializerConfig = CustomSerializer->DefaultConfig;
CloneArgs.Source = NetSerializerValuePointer(SrcElements[Idx].StructData.GetData());
CloneArgs.Target = NetSerializerValuePointer(DstElements[Idx].StructData.GetData());
CustomSerializer->CloneDynamicState(Context, CloneArgs);
}
else if (!CustomSerializer)
{
FStructNetSerializerConfig StructConfig;
StructConfig.StateDescriptor = Cache.FindDescriptor(SrcElements[Idx].StructName);
if (StructConfig.StateDescriptor.IsValid())
{
FNetCloneDynamicStateArgs CloneArgs = Args;
CloneArgs.NetSerializerConfig = &StructConfig;
CloneArgs.Source = NetSerializerValuePointer(SrcElements[Idx].StructData.GetData());
CloneArgs.Target = NetSerializerValuePointer(DstElements[Idx].StructData.GetData());
UE_NET_GET_SERIALIZER(FStructNetSerializer).CloneDynamicState(Context, CloneArgs);
}
}
}
}
}
template<typename QuantizedCollectionType, typename ElementType>
static void FreeDynamicStateImpl(FNetSerializationContext& Context, const FNetFreeDynamicStateArgs& Args, FNetworkPhysicsDescriptorCache& Cache)
{
QuantizedCollectionType& Value = *reinterpret_cast<QuantizedCollectionType*>(Args.Source);
ElementType* Elements = Value.Elements.GetData();
const uint32 Count = Value.Elements.Num();
for (uint32 Idx = 0u; Idx < Count; ++Idx)
{
FreeElement(Context, Elements[Idx], Cache);
}
Value.Elements.Free(Context);
}
template<typename QuantizedCollectionType, typename ElementType>
static void CollectNetReferencesImpl(FNetSerializationContext& Context, const FNetCollectReferencesArgs& Args, FNetworkPhysicsDescriptorCache& Cache)
{
const QuantizedCollectionType& Value = *reinterpret_cast<const QuantizedCollectionType*>(Args.Source);
const uint32 Count = Value.Elements.Num();
const ElementType* Elements = Value.Elements.GetData();
for (uint32 Idx = 0u; Idx < Count; ++Idx)
{
const ElementType& El = Elements[Idx];
if (El.StructName.IsNone())
{
continue;
}
// Dispatch to custom serializer if registered, otherwise FStructNetSerializer (mirrors FreeElement).
// Custom serializers may internally hold object references not reflected in StructDescriptorTraits.
const FNetSerializer* CustomSerializer = Cache.FindCustomSerializer(El.StructName);
if (CustomSerializer && EnumHasAnyFlags(CustomSerializer->Traits, ENetSerializerTraits::HasCustomNetReference))
{
FNetCollectReferencesArgs ElementArgs = Args;
ElementArgs.NetSerializerConfig = CustomSerializer->DefaultConfig;
ElementArgs.Source = NetSerializerValuePointer(El.StructData.GetData());
CustomSerializer->CollectNetReferences(Context, ElementArgs);
}
else if (!CustomSerializer)
{
if (!EnumHasAnyFlags(El.StructDescriptorTraits, EReplicationStateTraits::HasObjectReference))
{
continue;
}
FStructNetSerializerConfig StructConfig;
StructConfig.StateDescriptor = Cache.FindDescriptor(El.StructName);
if (!StructConfig.StateDescriptor.IsValid())
{
continue;
}
FNetCollectReferencesArgs ElementArgs = Args;
ElementArgs.NetSerializerConfig = &StructConfig;
ElementArgs.Source = NetSerializerValuePointer(El.StructData.GetData());
UE_NET_GET_SERIALIZER(FStructNetSerializer).CollectNetReferences(Context, ElementArgs);
}
}
}
// ============================================================
// FNetworkPhysicsPayloadNetSerializer
// ============================================================
struct FNetworkPhysicsPayloadNetSerializer
{
static constexpr uint32 Version = 0;
typedef FNetworkPhysicsPayload SourceType;
typedef FNetworkPhysicsPayloadQuantized QuantizedType;
typedef FNetworkPhysicsPayloadNetSerializerConfig ConfigType;
inline static const ConfigType DefaultConfig;
static void Serialize(FNetSerializationContext&, const FNetSerializeArgs&);
static void Deserialize(FNetSerializationContext&, const FNetDeserializeArgs&);
static void SerializeDelta(FNetSerializationContext&, const FNetSerializeDeltaArgs&);
static void DeserializeDelta(FNetSerializationContext&, const FNetDeserializeDeltaArgs&);
static void Quantize(FNetSerializationContext&, const FNetQuantizeArgs&);
static void Dequantize(FNetSerializationContext&, const FNetDequantizeArgs&);
static bool IsEqual(FNetSerializationContext&, const FNetIsEqualArgs&);
static bool Validate(FNetSerializationContext&, const FNetValidateArgs&);
};
UE_NET_IMPLEMENT_SERIALIZER(FNetworkPhysicsPayloadNetSerializer);
// Full serialize: write QuantizedServerFrame as packed uint32.
void FNetworkPhysicsPayloadNetSerializer::Serialize(FNetSerializationContext& Context, const FNetSerializeArgs& Args)
{
const QuantizedType& Value = *reinterpret_cast<const QuantizedType*>(Args.Source);
FNetBitStreamWriter* Writer = Context.GetBitStreamWriter();
UE_NET_TRACE_SCOPE(ServerFrame, *Writer, Context.GetTraceCollector(), ENetTraceVerbosity::Verbose);
WritePackedUint32(Context, Args, Value.QuantizedServerFrame);
}
// Full deserialize: read QuantizedServerFrame as packed uint32.
void FNetworkPhysicsPayloadNetSerializer::Deserialize(FNetSerializationContext& Context, const FNetDeserializeArgs& Args)
{
QuantizedType& Value = *reinterpret_cast<QuantizedType*>(Args.Target);
Value.QuantizedServerFrame = ReadPackedUint32(Context, Args);
}
// Delta serialize: 1 bit bIncrementalFrame, else sign + packed |delta|.
void FNetworkPhysicsPayloadNetSerializer::SerializeDelta(FNetSerializationContext& Context, const FNetSerializeDeltaArgs& Args)
{
const QuantizedType& Value = *reinterpret_cast<const QuantizedType*>(Args.Source);
const QuantizedType& PrevValue = *reinterpret_cast<const QuantizedType*>(Args.Prev);
FNetBitStreamWriter* Writer = Context.GetBitStreamWriter();
UE_NET_TRACE_SCOPE(ServerFrame, *Writer, Context.GetTraceCollector(), ENetTraceVerbosity::Verbose);
// QuantizedServerFrame stores (ServerFrame + 1) so delta==1 means consecutive frame
const bool bIncrementalFrame = (Value.QuantizedServerFrame == PrevValue.QuantizedServerFrame + 1u);
Writer->WriteBits(bIncrementalFrame, 1u);
if (!bIncrementalFrame)
{
const int64 Delta = static_cast<int64>(Value.QuantizedServerFrame) - static_cast<int64>(PrevValue.QuantizedServerFrame);
const bool bNegative = Delta < 0;
Writer->WriteBits(bNegative, 1u);
WritePackedUint32(Context, Args, static_cast<uint32>(FMath::Abs(Delta)));
}
}
// Delta deserialize: inverse of SerializeDelta.
void FNetworkPhysicsPayloadNetSerializer::DeserializeDelta(FNetSerializationContext& Context, const FNetDeserializeDeltaArgs& Args)
{
QuantizedType& Value = *reinterpret_cast<QuantizedType*>(Args.Target);
const QuantizedType& PrevValue = *reinterpret_cast<const QuantizedType*>(Args.Prev);
FNetBitStreamReader* Reader = Context.GetBitStreamReader();
const bool bIncrementalFrame = (Reader->ReadBits(1u) != 0u);
if (bIncrementalFrame)
{
Value.QuantizedServerFrame = PrevValue.QuantizedServerFrame + 1u;
}
else
{
const bool bNegative = (Reader->ReadBits(1u) != 0u);
const uint32 AbsDelta = ReadPackedUint32(Context, Args);
const int64 SignedDelta = bNegative ? -static_cast<int64>(AbsDelta) : static_cast<int64>(AbsDelta);
Value.QuantizedServerFrame = static_cast<uint32>(static_cast<int64>(PrevValue.QuantizedServerFrame) + SignedDelta);
}
}
// Quantize: store ServerFrame+1 as unsigned (0 == INDEX_NONE, matches legacy encoding).
void FNetworkPhysicsPayloadNetSerializer::Quantize(FNetSerializationContext&, const FNetQuantizeArgs& Args)
{
const SourceType& Source = *reinterpret_cast<const SourceType*>(Args.Source);
QuantizedType& Target = *reinterpret_cast<QuantizedType*>(Args.Target);
Target.QuantizedServerFrame = static_cast<uint32>(static_cast<int64>(Source.ServerFrame) + 1);
}
// Dequantize: recover ServerFrame from the unsigned stored value.
void FNetworkPhysicsPayloadNetSerializer::Dequantize(FNetSerializationContext&, const FNetDequantizeArgs& Args)
{
const QuantizedType& Source = *reinterpret_cast<const QuantizedType*>(Args.Source);
SourceType& Target = *reinterpret_cast<SourceType*>(Args.Target);
Target.ServerFrame = static_cast<int32>(static_cast<int64>(Source.QuantizedServerFrame) - 1);
}
bool FNetworkPhysicsPayloadNetSerializer::IsEqual(FNetSerializationContext&, const FNetIsEqualArgs& Args)
{
if (Args.bStateIsQuantized)
{
const QuantizedType& Value0 = *reinterpret_cast<const QuantizedType*>(Args.Source0);
const QuantizedType& Value1 = *reinterpret_cast<const QuantizedType*>(Args.Source1);
return Value0.QuantizedServerFrame == Value1.QuantizedServerFrame;
}
else
{
const SourceType& Value0 = *reinterpret_cast<const SourceType*>(Args.Source0);
const SourceType& Value1 = *reinterpret_cast<const SourceType*>(Args.Source1);
return Value0.ServerFrame == Value1.ServerFrame;
}
}
bool FNetworkPhysicsPayloadNetSerializer::Validate(FNetSerializationContext&, const FNetValidateArgs&)
{
return true;
}
// Registration: binds struct name "NetworkPhysicsPayload" to this serializer.
UE_NET_IMPLEMENT_FORWARDING_NETSERIALIZER_AND_REGISTRY_DELEGATES(NetworkPhysicsPayload, FNetworkPhysicsPayloadNetSerializer);
// ============================================================
// FNetworkPhysicsActionPayloadNetSerializer
// ============================================================
struct FNetworkPhysicsActionPayloadNetSerializer
{
static constexpr uint32 Version = 0;
typedef FNetworkPhysicsActionPayload SourceType;
typedef FNetworkPhysicsActionPayloadQuantized QuantizedType;
typedef FNetworkPhysicsActionPayloadNetSerializerConfig ConfigType;
inline static const ConfigType DefaultConfig;
static void Serialize(FNetSerializationContext&, const FNetSerializeArgs&);
static void Deserialize(FNetSerializationContext&, const FNetDeserializeArgs&);
static void SerializeDelta(FNetSerializationContext&, const FNetSerializeDeltaArgs&);
static void DeserializeDelta(FNetSerializationContext&, const FNetDeserializeDeltaArgs&);
static void Quantize(FNetSerializationContext&, const FNetQuantizeArgs&);
static void Dequantize(FNetSerializationContext&, const FNetDequantizeArgs&);
static bool IsEqual(FNetSerializationContext&, const FNetIsEqualArgs&);
static bool Validate(FNetSerializationContext&, const FNetValidateArgs&);
};
UE_NET_IMPLEMENT_SERIALIZER(FNetworkPhysicsActionPayloadNetSerializer);
void FNetworkPhysicsActionPayloadNetSerializer::Serialize(FNetSerializationContext& Context, const FNetSerializeArgs& Args)
{
const QuantizedType& Value = *reinterpret_cast<const QuantizedType*>(Args.Source);
FNetBitStreamWriter* Writer = Context.GetBitStreamWriter();
{
UE_NET_TRACE_SCOPE(ServerFrame, *Writer, Context.GetTraceCollector(), ENetTraceVerbosity::Verbose);
WritePackedUint32(Context, Args, Value.QuantizedServerFrame);
}
Writer->WriteBits(Value.SourceId, 32u);
Writer->WriteBits(Value.ActionId, 16u);
}
void FNetworkPhysicsActionPayloadNetSerializer::Deserialize(FNetSerializationContext& Context, const FNetDeserializeArgs& Args)
{
QuantizedType& Value = *reinterpret_cast<QuantizedType*>(Args.Target);
Value.QuantizedServerFrame = ReadPackedUint32(Context, Args);
FNetBitStreamReader* Reader = Context.GetBitStreamReader();
Value.SourceId = Reader->ReadBits(32u);
Value.ActionId = static_cast<uint16>(Reader->ReadBits(16u));
}
void FNetworkPhysicsActionPayloadNetSerializer::SerializeDelta(FNetSerializationContext& Context, const FNetSerializeDeltaArgs& Args)
{
const QuantizedType& Value = *reinterpret_cast<const QuantizedType*>(Args.Source);
const QuantizedType& PrevValue = *reinterpret_cast<const QuantizedType*>(Args.Prev);
FNetBitStreamWriter* Writer = Context.GetBitStreamWriter();
UE_NET_TRACE_SCOPE(ServerFrame, *Writer, Context.GetTraceCollector(), ENetTraceVerbosity::Verbose);
// Delta-encode ServerFrame (1 bit if consecutive)
const bool bIncrementalFrame = (Value.QuantizedServerFrame == PrevValue.QuantizedServerFrame + 1u);
Writer->WriteBits(bIncrementalFrame, 1u);
if (!bIncrementalFrame)
{
const int64 Delta = static_cast<int64>(Value.QuantizedServerFrame) - static_cast<int64>(PrevValue.QuantizedServerFrame);
const bool bNegative = Delta < 0;
Writer->WriteBits(bNegative, 1u);
WritePackedUint32(Context, Args, static_cast<uint32>(FMath::Abs(Delta)));
}
// SourceId and ActionId: write only if changed
const bool bSourceIdChanged = (Value.SourceId != PrevValue.SourceId);
Writer->WriteBits(bSourceIdChanged, 1u);
if (bSourceIdChanged)
{
Writer->WriteBits(Value.SourceId, 32u);
}
const bool bActionIdChanged = (Value.ActionId != PrevValue.ActionId);
Writer->WriteBits(bActionIdChanged, 1u);
if (bActionIdChanged)
{
Writer->WriteBits(Value.ActionId, 16u);
}
}
void FNetworkPhysicsActionPayloadNetSerializer::DeserializeDelta(FNetSerializationContext& Context, const FNetDeserializeDeltaArgs& Args)
{
QuantizedType& Value = *reinterpret_cast<QuantizedType*>(Args.Target);
const QuantizedType& PrevValue = *reinterpret_cast<const QuantizedType*>(Args.Prev);
FNetBitStreamReader* Reader = Context.GetBitStreamReader();
const bool bIncrementalFrame = (Reader->ReadBits(1u) != 0u);
if (bIncrementalFrame)
{
Value.QuantizedServerFrame = PrevValue.QuantizedServerFrame + 1u;
}
else
{
const bool bNegative = (Reader->ReadBits(1u) != 0u);
const uint32 AbsDelta = ReadPackedUint32(Context, Args);
const int64 SignedDelta = bNegative ? -static_cast<int64>(AbsDelta) : static_cast<int64>(AbsDelta);
Value.QuantizedServerFrame = static_cast<uint32>(static_cast<int64>(PrevValue.QuantizedServerFrame) + SignedDelta);
}
const bool bSourceIdChanged = (Reader->ReadBits(1u) != 0u);
Value.SourceId = bSourceIdChanged ? Reader->ReadBits(32u) : PrevValue.SourceId;
const bool bActionIdChanged = (Reader->ReadBits(1u) != 0u);
Value.ActionId = bActionIdChanged ? static_cast<uint16>(Reader->ReadBits(16u)) : PrevValue.ActionId;
}
void FNetworkPhysicsActionPayloadNetSerializer::Quantize(FNetSerializationContext&, const FNetQuantizeArgs& Args)
{
const SourceType& Source = *reinterpret_cast<const SourceType*>(Args.Source);
QuantizedType& Target = *reinterpret_cast<QuantizedType*>(Args.Target);
Target.QuantizedServerFrame = static_cast<uint32>(static_cast<int64>(Source.ServerFrame) + 1);
Target.SourceId = Source.SourceId;
Target.ActionId = Source.ActionId;
}
void FNetworkPhysicsActionPayloadNetSerializer::Dequantize(FNetSerializationContext&, const FNetDequantizeArgs& Args)
{
const QuantizedType& Source = *reinterpret_cast<const QuantizedType*>(Args.Source);
SourceType& Target = *reinterpret_cast<SourceType*>(Args.Target);
Target.ServerFrame = static_cast<int32>(static_cast<int64>(Source.QuantizedServerFrame) - 1);
Target.SourceId = Source.SourceId;
Target.ActionId = Source.ActionId;
}
bool FNetworkPhysicsActionPayloadNetSerializer::IsEqual(FNetSerializationContext&, const FNetIsEqualArgs& Args)
{
if (Args.bStateIsQuantized)
{
const QuantizedType& V0 = *reinterpret_cast<const QuantizedType*>(Args.Source0);
const QuantizedType& V1 = *reinterpret_cast<const QuantizedType*>(Args.Source1);
return V0.QuantizedServerFrame == V1.QuantizedServerFrame
&& V0.SourceId == V1.SourceId
&& V0.ActionId == V1.ActionId;
}
else
{
const SourceType& V0 = *reinterpret_cast<const SourceType*>(Args.Source0);
const SourceType& V1 = *reinterpret_cast<const SourceType*>(Args.Source1);
return V0.ServerFrame == V1.ServerFrame
&& V0.SourceId == V1.SourceId
&& V0.ActionId == V1.ActionId;
}
}
bool FNetworkPhysicsActionPayloadNetSerializer::Validate(FNetSerializationContext&, const FNetValidateArgs&)
{
return true;
}
UE_NET_IMPLEMENT_FORWARDING_NETSERIALIZER_AND_REGISTRY_DELEGATES(NetworkPhysicsActionPayload, FNetworkPhysicsActionPayloadNetSerializer);
// ============================================================
// FNetworkPhysicsDataCollectionNetSerializer
// ============================================================
struct FNetworkPhysicsDataCollectionNetSerializer
{
static constexpr uint32 Version = 0;
static constexpr bool bHasDynamicState = true;
static constexpr bool bIsForwardingSerializer = true;
static constexpr bool bHasCustomNetReference = true;
typedef FNetworkPhysicsDataCollection SourceType;
typedef FNetworkPhysicsDataCollectionQuantized QuantizedType;
typedef FNetworkPhysicsDataCollectionNetSerializerConfig ConfigType;
inline static const ConfigType DefaultConfig;
static void Serialize(FNetSerializationContext&, const FNetSerializeArgs&);
static void Deserialize(FNetSerializationContext&, const FNetDeserializeArgs&);
static void SerializeDelta(FNetSerializationContext&, const FNetSerializeDeltaArgs&);
static void DeserializeDelta(FNetSerializationContext&, const FNetDeserializeDeltaArgs&);
static void Quantize(FNetSerializationContext&, const FNetQuantizeArgs&);
static void Dequantize(FNetSerializationContext&, const FNetDequantizeArgs&);
static bool IsEqual(FNetSerializationContext&, const FNetIsEqualArgs&);
static bool Validate(FNetSerializationContext&, const FNetValidateArgs&);
static void CloneDynamicState(FNetSerializationContext&, const FNetCloneDynamicStateArgs&);
static void FreeDynamicState(FNetSerializationContext&, const FNetFreeDynamicStateArgs&);
static void CollectNetReferences(FNetSerializationContext&, const FNetCollectReferencesArgs&);
private:
// Serialize one element's struct data with delta compression.
// Uses Prev as the delta source if available and type-matching, otherwise a zero-initialized default.
// Type identification is handled at the collection level - this only writes bValid + struct data.
// SharedZeroStorage is grown in place per element; the owning top-level function frees it once at scope end.
static void SerializeElementDelta(FNetSerializationContext& Context, const FNetSerializeDeltaArgs& BaseArgs,
const FNetworkPhysicsElementQuantized& Curr, const FNetworkPhysicsElementQuantized* Prev,
FNetSerializerAlignedStorage& SharedZeroStorage,
FNetworkPhysicsDescriptorCache& Cache);
// Deserialize one element's struct data with delta decompression (mirrors SerializeElementDelta).
static void DeserializeElementDelta(FNetSerializationContext& Context, const FNetDeserializeDeltaArgs& BaseArgs,
FNetworkPhysicsElementQuantized& Target, const FNetworkPhysicsElementQuantized* Prev,
FNetSerializerAlignedStorage& SharedZeroStorage,
FNetworkPhysicsDescriptorCache& Cache);
// Set up an element's storage for a given struct type if it doesn't match already.
static void EnsureElementType(FNetSerializationContext& Context, FNetworkPhysicsElementQuantized& Element,
FName TypeName, const UScriptStruct* Struct, FNetworkPhysicsDescriptorCache& Cache);
// Thread-safe descriptor/serializer cache, shared across all instances of this serializer.
inline static FNetworkPhysicsDescriptorCache DescriptorCache;
};
UE_NET_IMPLEMENT_SERIALIZER(FNetworkPhysicsDataCollectionNetSerializer);
// ----- Element-Level Helpers -----
// Ensure an element's quantized storage matches the expected struct type.
// If the type changed, frees old storage and allocates new storage sized for the new type.
void FNetworkPhysicsDataCollectionNetSerializer::EnsureElementType(
FNetSerializationContext& Context, FNetworkPhysicsElementQuantized& Element,
FName TypeName, const UScriptStruct* Struct, FNetworkPhysicsDescriptorCache& Cache)
{
// Already the correct type, nothing to do
if (TypeName == Element.StructName)
{
return;
}
// Release old storage before re-allocating for the new type
FreeElement(Context, Element, Cache);
// Check if the struct type has a registered custom Iris serializer (e.g. FNetworkPhysicsPayloadNetSerializer)
const FNetSerializer* CustomSerializer = Cache.FindCustomSerializer(TypeName);
if (CustomSerializer)
{
// Custom serializer defines its own quantized size/alignment
Element.StructData.AdjustSize(Context, CustomSerializer->QuantizedTypeSize, CustomSerializer->QuantizedTypeAlignment);
Element.StructDescriptorTraits = EnumHasAnyFlags(CustomSerializer->Traits, ENetSerializerTraits::HasDynamicState)
? EReplicationStateTraits::HasDynamicState : EReplicationStateTraits::None;
}
else
{
// No custom serializer - build a replication descriptor from UStruct reflection and use its sizing
TRefCountPtr<const FReplicationStateDescriptor> Descriptor = Cache.FindOrAddDescriptor(Struct);
if (ensureMsgf(Descriptor.IsValid(), TEXT("FNetworkPhysicsDataCollectionNetSerializer: failed to build descriptor for %s"), ToCStr(TypeName.ToString())))
{
Element.StructData.AdjustSize(Context, Descriptor->InternalSize, Descriptor->InternalAlignment);
Element.StructDescriptorTraits = Descriptor->Traits;
}
}
Element.StructName = TypeName;
}
// Serialize one element's data to the bit stream.
// Writes: [1 bit bValid] [struct data (always delta-compressed)]
// The concrete struct type is NOT written here - it is written once at the collection level.
// Delta source: the previous element if available and type-matching, otherwise a zero-initialized default.
// This avoids full serialization entirely - Iris's baseline acks rarely arrive in time for per-frame
// physics data, so always using delta (even against zero) gives better compression for element[0].
void FNetworkPhysicsDataCollectionNetSerializer::SerializeElementDelta(
FNetSerializationContext& Context,
const FNetSerializeDeltaArgs& BaseArgs,
const FNetworkPhysicsElementQuantized& Curr,