UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
DoubleFloat.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "Math/MathFwd.h"
7#include "Math/Matrix.h"
9#include "Math/Vector.h"
10#include "Math/Vector4.h"
11
12// A high-precision floating point type, consisting of two 32-bit floats (High & Low).
13// Usable where doubles (fp64) are not an option.
14// See also the DoubleFloat.ush shader header.
16{
17 double GetDouble() const
18 {
19 return static_cast<double>(High) + static_cast<double>(Low);
20 }
21
22 [[nodiscard]] FDFScalar(double In)
23 {
24 High = static_cast<float>(In);
25 Low = static_cast<float>(In - High);
26 }
27
28 FDFScalar(float High, float Low)
29 : High(High), Low(Low)
30 { }
31
32 FDFScalar() = default;
33
34 float High = 0;
35 float Low = 0;
36};
37
39{
41 {
42 return FVector2d{ X().GetDouble(), Y().GetDouble() };
43 }
44
45 template<typename TInputScalar = double>
47 {
48 FDFScalar X(In.X);
49 FDFScalar Y(In.Y);
50 High = { X.High, Y.High };
51 Low = { X.Low, Y.Low };
52 }
53
57
58 [[nodiscard]] FDFVector2() = default;
59
60 [[nodiscard]] FDFScalar X() const
61 {
62 return { High.X, Low.X };
63 }
64
65 [[nodiscard]] FDFScalar Y() const
66 {
67 return { High.Y, Low.Y };
68 }
69
72};
73
75{
77 {
78 return FVector3d{ X().GetDouble(), Y().GetDouble(), Z().GetDouble() };
79 }
80
81 template<typename TInputScalar = double>
83 {
84 FDFScalar X(In.X);
85 FDFScalar Y(In.Y);
86 FDFScalar Z(In.Z);
87 High = { X.High, Y.High, Z.High };
88 Low = { X.Low, Y.Low, Z.Low };
89 }
90
94
95 FDFVector3() = default;
96
97 [[nodiscard]] FDFScalar X() const
98 {
99 return { High.X, Low.X };
100 }
101
103 {
104 return { High.Y, Low.Y };
105 }
106
108 {
109 return { High.Z, Low.Z };
110 }
111
114};
115
117{
119 {
120 return FVector4d{ X().GetDouble(), Y().GetDouble(), Z().GetDouble(), W().GetDouble() };
121 }
122
123 template<typename TInputScalar = double>
125 {
126 FDFScalar X(In.X);
127 FDFScalar Y(In.Y);
128 FDFScalar Z(In.Z);
129 FDFScalar W(In.W);
130 High = FVector4f{ X.High, Y.High, Z.High, W.High };
131 Low = FVector4f{ X.Low, Y.Low, Z.Low, W.Low };
132 }
133
134 template<typename TInputScalar = double>
136 {
137 FDFScalar X(In.X);
138 FDFScalar Y(In.Y);
139 FDFScalar Z(In.Z);
140 FDFScalar W(InW);
141 High = FVector4f{ X.High, Y.High, Z.High, W.High };
142 Low = FVector4f{ X.Low, Y.Low, Z.Low, W.Low };
143 }
144
148
149 FDFVector4() = default;
150
152 {
153 return { High.X, Low.X };
154 }
155
157 {
158 return { High.Y, Low.Y };
159 }
160
162 {
163 return { High.Z, Low.Z };
164 }
165
167 {
168 return { High.W, Low.W };
169 }
170
173};
174
175// Transforms *to* absolute world space
177{
181
182 FDFMatrix() = default;
183
185 FVector3f PostTranslation{}; // Added to result, *after* multiplying 'M'
186
187 // Check if the origin of the matrix is small enough to ensure the precision >= UE_DF_MIN_PRECISION
189
190 // Apply post-translation to matrix
193
196};
197
198// Transforms *from* absolute world space
200{
204
205 FDFInverseMatrix() = default;
206
208 FVector3f PreTranslation{}; // Subtracted from input position *before* multiplying 'M'
209
210 // Apply pre-translation to matrix
213};
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition DoubleFloat.h:200
FDFInverseMatrix()=default
static CORE_API FDFInverseMatrix MakeFromRelativeWorldMatrix(const FVector3f Origin, const FMatrix &FromWorld)
Definition DoubleFloat.cpp:63
FDFInverseMatrix(FMatrix44f M, FVector3f PreTranslation)
Definition DoubleFloat.h:201
FMatrix44f M
Definition DoubleFloat.h:207
FVector3f PreTranslation
Definition DoubleFloat.h:208
static CORE_API FMatrix MakeFromRelativeWorldMatrixDouble(const FVector Origin, const FMatrix &FromWorld)
Definition DoubleFloat.cpp:68
Definition DoubleFloat.h:177
FDFMatrix(FMatrix44f M, FVector3f PostTranslation)
Definition DoubleFloat.h:178
static CORE_API FMatrix44f SafeCastMatrix(const FMatrix &Matrix)
Definition DoubleFloat.cpp:27
FVector3f PostTranslation
Definition DoubleFloat.h:185
static CORE_API FDFMatrix MakeClampedToRelativeWorldMatrix(const FVector3f Origin, const FMatrix &ToWorld)
Definition DoubleFloat.cpp:58
static CORE_API FMatrix MakeToRelativeWorldMatrixDouble(const FVector Origin, const FMatrix &ToWorld)
Definition DoubleFloat.cpp:32
FDFMatrix()=default
static CORE_API FDFMatrix MakeToRelativeWorldMatrix(const FVector3f Origin, const FMatrix &ToWorld)
Definition DoubleFloat.cpp:37
static CORE_API FMatrix MakeClampedToRelativeWorldMatrixDouble(const FVector Origin, const FMatrix &ToWorld)
Definition DoubleFloat.cpp:42
FMatrix44f M
Definition DoubleFloat.h:184
Definition DoubleFloat.h:16
float Low
Definition DoubleFloat.h:35
FDFScalar(double In)
Definition DoubleFloat.h:22
FDFScalar(float High, float Low)
Definition DoubleFloat.h:28
float High
Definition DoubleFloat.h:34
FDFScalar()=default
double GetDouble() const
Definition DoubleFloat.h:17
Definition DoubleFloat.h:39
FVector2f High
Definition DoubleFloat.h:70
FDFVector2(const UE::Math::TVector2< TInputScalar > &In)
Definition DoubleFloat.h:46
FDFScalar Y() const
Definition DoubleFloat.h:65
FDFScalar X() const
Definition DoubleFloat.h:60
FDFVector2()=default
FVector2d GetVector2d() const
Definition DoubleFloat.h:40
FDFVector2(FVector2f High, FVector2f Low)
Definition DoubleFloat.h:54
FVector2f Low
Definition DoubleFloat.h:71
Definition DoubleFloat.h:75
FVector3f Low
Definition DoubleFloat.h:113
FDFScalar Y() const
Definition DoubleFloat.h:102
FDFVector3(FVector3f High, FVector3f Low)
Definition DoubleFloat.h:91
FVector3d GetVector3d() const
Definition DoubleFloat.h:76
FDFVector3(const UE::Math::TVector< TInputScalar > &In)
Definition DoubleFloat.h:82
FDFScalar Z() const
Definition DoubleFloat.h:107
FDFScalar X() const
Definition DoubleFloat.h:97
FVector3f High
Definition DoubleFloat.h:112
FDFVector3()=default
Definition DoubleFloat.h:117
FDFScalar W() const
Definition DoubleFloat.h:166
FDFVector4()=default
FVector4f High
Definition DoubleFloat.h:171
FDFVector4(FVector4f High, FVector4f Low)
Definition DoubleFloat.h:145
FDFScalar Z() const
Definition DoubleFloat.h:161
FVector4d GetVector4d() const
Definition DoubleFloat.h:118
FDFScalar Y() const
Definition DoubleFloat.h:156
FDFVector4(const UE::Math::TVector4< TInputScalar > &In)
Definition DoubleFloat.h:124
FDFScalar X() const
Definition DoubleFloat.h:151
FVector4f Low
Definition DoubleFloat.h:172
FDFVector4(const UE::Math::TVector< TInputScalar > &In, TInputScalar InW)
Definition DoubleFloat.h:135
T Y
Definition Vector2D.h:52
T X
Definition Vector2D.h:49
T Y
Definition Vector4.h:46
T Z
Definition Vector4.h:49
T W
Definition Vector4.h:52
T X
Definition Vector4.h:43
T Z
Definition Vector.h:68
T Y
Definition Vector.h:65
T X
Definition Vector.h:62