6#include "Math/MathFwd.h"
7#include "Math/Matrix.h"
8#include "Math/UnrealMathUtility.h"
9#include "Math/Vector.h"
10#include "Math/Vector4.h"
11#include "Misc/LargeWorldCoordinates.h"
13template <
typename TScalar>
14struct TLargeWorldRenderScalar
17 using VectorType = UE::Math::TVector<TScalar>;
21 static TScalar GetTileSize();
22 static FVector3f GetTileFor(FVector InPosition);
24 static TScalar MakeTile(
double InValue)
26 return static_cast<TScalar>(FMath::FloorToDouble(InValue / GetTileSize() + 0.5));
29 static TScalar MakeQuantizedTile(
double InValue,
double InQuantization)
31 return static_cast<TScalar>(FMath::FloorToDouble((InValue / GetTileSize()) * InQuantization + 0.5) / InQuantization);
34 static VectorType MakeTile(
const FVector& InValue)
36 return VectorType(MakeTile(InValue.X), MakeTile(InValue.Y), MakeTile(InValue.Z));
39 static VectorType MakeQuantizedTile(
const FVector& InValue,
double InQuantization)
41 return VectorType(MakeQuantizedTile(InValue.X, InQuantization), MakeQuantizedTile(InValue.Y, InQuantization), MakeQuantizedTile(InValue.Z, InQuantization));
44 static FMatrix44f SafeCastMatrix(
const FMatrix& Matrix);
45 static FMatrix44f MakeToRelativeWorldMatrix(
const FVector Origin,
const FMatrix& ToWorld);
46 static FMatrix MakeToRelativeWorldMatrixDouble(
const FVector Origin,
const FMatrix& ToWorld);
47 static FMatrix44f MakeFromRelativeWorldMatrix(
const FVector Origin,
const FMatrix& FromWorld);
48 static FMatrix MakeFromRelativeWorldMatrixDouble(
const FVector Origin,
const FMatrix& FromWorld);
49 static FMatrix44f MakeClampedToRelativeWorldMatrix(
const FVector Origin,
const FMatrix& ToWorld);
50 static FMatrix MakeClampedToRelativeWorldMatrixDouble(
const FVector Origin,
const FMatrix& ToWorld);
52 template <
typename TResult =
float>
53 TResult GetTile()
const {
return static_cast<TResult>(Tile); }
54 template <
typename TResult =
float>
55 TResult GetOffset()
const {
return static_cast<TResult>(Offset); }
56 UE_DEPRECATED(5.2,
"GetTileAsDouble is deprecated, please use GetTile<double>() instead.")
57 double GetTileAsDouble()
const {
return GetTile<
double>(); }
58 UE_DEPRECATED(5.2,
"GetOffsetAsDouble is deprecated, please use GetOffset<double>() instead.")
59 double GetOffsetAsDouble()
const {
return GetOffset<
double>(); }
60 double GetTileOffset()
const {
return static_cast<
double>(Tile) * GetTileSize(); }
61 double GetAbsolute()
const {
return GetTileOffset() + Offset; }
63 TLargeWorldRenderScalar() : Tile(
static_cast<TScalar>(0.0)), Offset(
static_cast<TScalar>(0.0)) {}
64 TLargeWorldRenderScalar(TScalar InTile, TScalar InOffset) : Tile(
static_cast<TScalar>(InTile)), Offset(
static_cast<TScalar>(InOffset)) {}
66 template<
typename TInputScalar =
double>
67 explicit TLargeWorldRenderScalar(
const TLargeWorldRenderScalar<TInputScalar>& In)
68 : TLargeWorldRenderScalar(In.Tile, In.Offset)
71 TLargeWorldRenderScalar(
double InAbsolute)
74 Tile = MakeTile(InAbsolute);
75 Offset =
static_cast<TScalar>(InAbsolute - GetTileOffset());
80 void Validate(
double InAbsolute);
85using FLargeWorldRenderScalar = TLargeWorldRenderScalar<
double>;
87template<
typename TScalar>
95 template<
typename TResult =
float>
106 template<
typename TResult =
float>
117 template<
typename TInputScalar =
double>
127 template<
typename TInputScalar =
double>
132 template<
typename TInputScalar =
double>
139 template<
typename TInputScalar>
#define UE_DEPRECATED(Version, Message)
TLargeWorldRenderPosition(const UE::Math::TVector4< TInputScalar > &InWorldPosition)
FVector GetAbsolute() const
TLargeWorldRenderPosition(const UE::Math::TVector< TInputScalar > &InWorldPosition)
TLargeWorldRenderPosition()
TLargeWorldRenderPosition(const UE::Math::TVector< TInputScalar > &InTilePosition, const UE::Math::TVector< TInputScalar > &InRelativePosition)
UE::Math::TVector< TResult > GetTile() const
FVector GetTileOffset() const
TLargeWorldRenderPosition(const TLargeWorldRenderPosition< TInputScalar > &In)
UE::Math::TVector< TResult > GetOffset() const