UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
QuantizedVectorSerialization.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreTypes.h"
6#include "Math/MathFwd.h"
8
9namespace UE::Net
10{
11
12/* Scales the supplied vector and then rounds to an integer value which is serialized.
13 * If scaling cannot improve the precision of any of the components the value will not be scaled before rounding.
14 * If scaling produces a value that would cause any of the components to be clamped then serialization
15 * will fallback to send full precision components.
16 * N.B. The Vector3f and Vector3d variants are bit compatible with eachother, but it's discouraged to mix types
17 * when writing and reading.
18 */
21
22/* Reads a quantized vector that was written using WriteQuantizedVector with the same scale. */
25
26/* Quantize a vector using the same quantization as WriteQuantizedVector followed by ReadQuantizedVector. */
29
30template<int32 Scale>
32{
33 if (Ar.IsLoading())
34 {
35 return ReadQuantizedVector(Scale, Value, Ar);
36 }
37 else
38 {
39 return WriteQuantizedVector(Scale, Value, Ar);
40 }
41}
42
43}
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition Archive.h:1208
UE_FORCEINLINE_HINT bool IsLoading() const
Definition Archive.h:236
bool ReadQuantizedVector(const int32 Scale, T &Value, FArchive &Ar)
Definition QuantizedVectorSerialization.cpp:111
bool WriteQuantizedVector(const int32 Scale, const T &Value, FArchive &Ar)
Definition QuantizedVectorSerialization.cpp:38
T QuantizeVector(const int32 Scale, const T &Value)
Definition QuantizedVectorSerialization.cpp:191
Definition NetworkVersion.cpp:28
bool SerializeQuantizedVector(FVector &Value, FArchive &Ar)
Definition QuantizedVectorSerialization.h:31