UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UnrealMathVectorConstants.h.inl
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5// HEADER_UNIT_SKIP - Not included directly
6// IWYU pragma: private
7
9
11// constexpr floating point vector constant creation functions that bypass SIMD intrinsic setters
12//
13// Added new functions instead of constexprifying MakeVectorRegisterXyz to avoid small risk of impacting codegen.
14// Long-term, we should only have one set of constexpr make functions without the Constant suffix.
16
21
27
28FORCEINLINE constexpr VectorRegister4Float MakeVectorRegisterConstant(float X, float Y, float Z, float W)
29{
31}
32
33FORCEINLINE constexpr VectorRegister4Double MakeVectorRegisterConstant(double X, double Y, double Z, double W)
34{
36}
37
39{
40 inline constexpr VectorRegister4Float FloatOne = MakeVectorRegisterFloatConstant(1.f, 1.f, 1.f, 1.f);
41 inline constexpr VectorRegister4Float FloatZero = MakeVectorRegisterFloatConstant(0.f, 0.f, 0.f, 0.f);
42 inline constexpr VectorRegister4Float FloatMinusOne = MakeVectorRegisterFloatConstant(-1.f, -1.f, -1.f, -1.f);
43 inline constexpr VectorRegister4Float Float0001 = MakeVectorRegisterFloatConstant(0.f, 0.f, 0.f, 1.f);
44 inline constexpr VectorRegister4Float Float1000 = MakeVectorRegisterFloatConstant(1.f, 0.f, 0.f, 0.f);
45 inline constexpr VectorRegister4Float Float1110 = MakeVectorRegisterFloatConstant(1.f, 1.f, 1.f, 0.f);
46 inline constexpr VectorRegister4Float SmallLengthThreshold = MakeVectorRegisterFloatConstant(1.e-8f, 1.e-8f, 1.e-8f, 1.e-8f);
47 inline constexpr VectorRegister4Float FloatOneHundredth = MakeVectorRegisterFloatConstant(0.01f, 0.01f, 0.01f, 0.01f);
48 inline constexpr VectorRegister4Float Float111_Minus1 = MakeVectorRegisterFloatConstant( 1.f, 1.f, 1.f, -1.f );
50 inline constexpr VectorRegister4Float FloatOneHalf = MakeVectorRegisterFloatConstant( 0.5f, 0.5f, 0.5f, 0.5f );
51 inline constexpr VectorRegister4Float FloatMinusOneHalf = MakeVectorRegisterFloatConstant( -0.5f, -0.5f, -0.5f, -0.5f );
56
60 inline constexpr VectorRegister4Double DoubleMinusOne = MakeVectorRegisterDoubleConstant(-1.0, -1.0, -1.0, -1.0);
61 inline constexpr VectorRegister4Double Double0001 = MakeVectorRegisterDoubleConstant(0.0f, 0.0, 0.0, 1.0);
74
75 inline constexpr VectorRegister Vector0001 = MakeVectorRegisterConstant(0.0, 0.0, 0.0, 1.0);
76 inline constexpr VectorRegister Vector1110 = MakeVectorRegisterConstant(1.0, 1.0, 1.0, 0.0);
77
81
83 inline constexpr VectorRegister4Float QINV_SIGN_MASK = MakeVectorRegisterFloatConstant( -1.f, -1.f, -1.f, 1.f );
85
92
93 inline constexpr VectorRegister4Float DEG_TO_RAD = MakeVectorRegisterConstant(UE_PI/(180.f), UE_PI/(180.f), UE_PI/(180.f), UE_PI/(180.f));
94 inline constexpr VectorRegister4Float DEG_TO_RAD_HALF = MakeVectorRegisterConstant((UE_PI/180.f)*0.5f, (UE_PI/180.f)*0.5f, (UE_PI/180.f)*0.5f, (UE_PI/180.f)*0.5f);
95 inline constexpr VectorRegister4Float RAD_TO_DEG = MakeVectorRegisterConstant((180.f)/UE_PI, (180.f)/UE_PI, (180.f)/UE_PI, (180.f)/UE_PI);
97 inline constexpr VectorRegister4Double DOUBLE_DEG_TO_RAD_HALF = MakeVectorRegisterConstant((UE_DOUBLE_PI/180.) * 0.5, (UE_DOUBLE_PI/180.) * 0.5, (UE_DOUBLE_PI/180.) * 0.5, (UE_DOUBLE_PI/180.) * 0.5);
99
103
105 inline VectorRegister4Float SignBit() { return MakeVectorRegisterFloatMask( 0x80000000, 0x80000000, 0x80000000, 0x80000000); }
106 inline VectorRegister4Float SignMask() { return MakeVectorRegisterFloatMask(~0x80000000, ~0x80000000, ~0x80000000, ~0x80000000); }
107 inline constexpr VectorRegister4Int IntSignBit = MakeVectorRegisterIntConstant( 0x80000000, 0x80000000, 0x80000000, 0x80000000);
108 inline constexpr VectorRegister4Int IntSignMask = MakeVectorRegisterIntConstant(~0x80000000, ~0x80000000, ~0x80000000, ~0x80000000);
109
113
114 inline VectorRegister4Double DoubleSignBit() { return MakeVectorRegisterDoubleMask(uint64(1) << 63, uint64(1) << 63, uint64(1) << 63, uint64(1) << 63); }
115 inline VectorRegister4Double DoubleSignMask() { return MakeVectorRegisterDoubleMask(~(uint64(1) << 63), ~(uint64(1) << 63), ~(uint64(1) << 63), ~(uint64(1) << 63)); }
116
118 inline VectorRegister4Float FloatInfinity() { return MakeVectorRegisterFloatMask((uint32)0x7F800000, (uint32)0x7F800000, (uint32)0x7F800000, (uint32)0x7F800000); }
119 inline VectorRegister4Double DoubleInfinity() { return MakeVectorRegisterDoubleMask((uint64)0x7FF0000000000000, (uint64)0x7FF0000000000000, (uint64)0x7FF0000000000000, (uint64)0x7FF0000000000000); }
120
122 inline constexpr VectorRegister4Float TwoPi = MakeVectorRegisterConstant(2.0f*UE_PI, 2.0f*UE_PI, 2.0f*UE_PI, 2.0f*UE_PI);
124 inline constexpr VectorRegister4Float PiByFour = MakeVectorRegisterConstant(0.25f*UE_PI, 0.25f*UE_PI, 0.25f*UE_PI, 0.25f*UE_PI);
125 inline constexpr VectorRegister4Float OneOverPi = MakeVectorRegisterConstant(1.0f / UE_PI, 1.0f / UE_PI, 1.0f / UE_PI, 1.0f / UE_PI);
126 inline constexpr VectorRegister4Float OneOverTwoPi = MakeVectorRegisterConstant(1.0f / (2.0f*UE_PI), 1.0f / (2.0f*UE_PI), 1.0f / (2.0f*UE_PI), 1.0f / (2.0f*UE_PI));
127
133 inline constexpr VectorRegister4Double DoubleOneOverTwoPi = MakeVectorRegisterDoubleConstant(1.0 / (2.0 * UE_DOUBLE_PI), 1.0 / (2.0 * UE_DOUBLE_PI), 1.0 / (2.0 * UE_DOUBLE_PI), 1.0 / (2.0 * UE_DOUBLE_PI));
134
135 inline constexpr VectorRegister4Float Float255 = MakeVectorRegisterConstant(255.0f, 255.0f, 255.0f, 255.0f);
136 inline constexpr VectorRegister4Float Float127 = MakeVectorRegisterConstant(127.0f, 127.0f, 127.0f, 127.0f);
137 inline constexpr VectorRegister4Float FloatNeg127 = MakeVectorRegisterConstant(-127.0f, -127.0f, -127.0f, -127.0f);
138 inline constexpr VectorRegister4Float Float360 = MakeVectorRegisterConstant(360.f, 360.f, 360.f, 360.f);
139 inline constexpr VectorRegister4Float Float180 = MakeVectorRegisterConstant(180.f, 180.f, 180.f, 180.f);
140
141 inline constexpr VectorRegister4Double Double255 = MakeVectorRegisterDoubleConstant(255.0, 255.0, 255.0, 255.0);
142 inline constexpr VectorRegister4Double Double127 = MakeVectorRegisterDoubleConstant(127.0, 127.0, 127.0, 127.0);
143 inline constexpr VectorRegister4Double DoubleNeg127 = MakeVectorRegisterDoubleConstant(-127.0, -127.0, -127.0, -127.0);
144 inline constexpr VectorRegister4Double Double360 = MakeVectorRegisterDoubleConstant(360., 360., 360., 360.);
145 inline constexpr VectorRegister4Double Double180 = MakeVectorRegisterDoubleConstant(180., 180., 180., 180.);
146
147 // All float numbers greater than or equal to this have no fractional value.
150
151 inline constexpr VectorRegister4Float FloatTwo = MakeVectorRegisterConstant(2.0f, 2.0f, 2.0f, 2.0f);
152 inline constexpr uint32 AlmostTwoBits = 0x3fffffff;
154
156 inline constexpr uint64 DoubleAlmostTwoBits = 0x3FFFFFFFFFFFFFFF;
158}
#define FORCEINLINE
Definition AndroidPlatform.h:140
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
#define X(Name, Desc)
Definition FormatStringSan.h:47
FORCEINLINE constexpr VectorRegister4Float MakeVectorRegisterFloatConstant(float X, float Y, float Z, float W)
Definition UnrealMathFPU.h:297
FORCEINLINE VectorRegister4Double MakeVectorRegisterDoubleMask(uint64 X, uint64 Y, uint64 Z, uint64 W)
Definition UnrealMathFPU.h:206
FORCEINLINE constexpr VectorRegister4Int MakeVectorRegisterIntConstant(int32 X, int32 Y, int32 Z, int32 W)
Definition UnrealMathFPU.h:292
FORCEINLINE constexpr VectorRegister2Double MakeVectorRegister2DoubleConstant(double X, double Y)
Definition UnrealMathFPU.h:302
FORCEINLINE VectorRegister4Float MakeVectorRegisterFloatMask(uint32 X, uint32 Y, uint32 Z, uint32 W)
Definition UnrealMathFPU.h:201
#define UE_DOUBLE_PI
Definition UnrealMathUtility.h:138
#define UE_DOUBLE_SMALL_NUMBER
Definition UnrealMathUtility.h:139
#define UE_PI
Definition UnrealMathUtility.h:129
#define UE_BIG_NUMBER
Definition UnrealMathUtility.h:132
#define UE_DOUBLE_KINDA_SMALL_NUMBER
Definition UnrealMathUtility.h:140
#define UE_SMALL_NUMBER
Definition UnrealMathUtility.h:130
#define UE_DOUBLE_BIG_NUMBER
Definition UnrealMathUtility.h:141
#define UE_DOUBLE_NON_FRACTIONAL
Definition UnrealMathUtility.h:144
#define UE_DOUBLE_THRESH_QUAT_NORMALIZED
Definition UnrealMathUtility.h:234
#define UE_THRESH_QUAT_NORMALIZED
Definition UnrealMathUtility.h:215
#define UE_KINDA_SMALL_NUMBER
Definition UnrealMathUtility.h:131
#define UE_FLOAT_NON_FRACTIONAL
Definition UnrealMathUtility.h:135
FORCEINLINE constexpr VectorRegister4Double MakeVectorRegisterDoubleConstant(VectorRegister2Double XY, VectorRegister2Double ZW)
Definition UnrealMathVectorConstants.h.inl:17
FORCEINLINE constexpr VectorRegister4Float MakeVectorRegisterConstant(float X, float Y, float Z, float W)
Definition UnrealMathVectorConstants.h.inl:28
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition UnrealMathVectorConstants.h.inl:39
constexpr VectorRegister4Float SmallLengthThreshold
Definition UnrealMathVectorConstants.h.inl:46
constexpr VectorRegister4Double DoubleMinus1_111
Definition UnrealMathVectorConstants.h.inl:67
VectorRegister4Float FloatInfinity()
Definition UnrealMathVectorConstants.h.inl:118
VectorRegister4Double DoubleSignMask()
Definition UnrealMathVectorConstants.h.inl:115
constexpr VectorRegister4Int IntSignMask
Definition UnrealMathVectorConstants.h.inl:108
constexpr VectorRegister4Double DoubleOneHalf
Definition UnrealMathVectorConstants.h.inl:68
constexpr VectorRegister4Float FloatZero
Definition UnrealMathVectorConstants.h.inl:41
constexpr VectorRegister4Float ThreshQuatNormalized
Definition UnrealMathVectorConstants.h.inl:54
constexpr VectorRegister4Float FloatOne
Definition UnrealMathVectorConstants.h.inl:40
constexpr VectorRegister4Double Double1000
Definition UnrealMathVectorConstants.h.inl:62
constexpr VectorRegister4Double Double111_Minus1
Definition UnrealMathVectorConstants.h.inl:66
constexpr VectorRegister4Float FloatMinusOne
Definition UnrealMathVectorConstants.h.inl:42
constexpr VectorRegister4Int IntZero
Definition UnrealMathVectorConstants.h.inl:79
constexpr VectorRegister4Double DoubleThreshQuatNormalized
Definition UnrealMathVectorConstants.h.inl:72
constexpr VectorRegister4Int IntMinusOne
Definition UnrealMathVectorConstants.h.inl:80
constexpr VectorRegister4Float Float255
Definition UnrealMathVectorConstants.h.inl:135
constexpr VectorRegister4Float OneOverTwoPi
Definition UnrealMathVectorConstants.h.inl:126
constexpr VectorRegister4Float FloatTwo
Definition UnrealMathVectorConstants.h.inl:151
constexpr VectorRegister4Float SmallNumber
Definition UnrealMathVectorConstants.h.inl:53
constexpr VectorRegister4Double DoubleOneHundredth
Definition UnrealMathVectorConstants.h.inl:65
VectorRegister4Double DoubleSignBit()
Definition UnrealMathVectorConstants.h.inl:114
constexpr VectorRegister4Double DOUBLE_DEG_TO_RAD
Definition UnrealMathVectorConstants.h.inl:96
constexpr VectorRegister4Int IntAllMask
Definition UnrealMathVectorConstants.h.inl:110
constexpr VectorRegister4Float QINV_SIGN_MASK
Definition UnrealMathVectorConstants.h.inl:83
constexpr VectorRegister4Float FloatNeg127
Definition UnrealMathVectorConstants.h.inl:137
constexpr VectorRegister4Double Double127
Definition UnrealMathVectorConstants.h.inl:142
constexpr VectorRegister4Float FloatMinusOneHalf
Definition UnrealMathVectorConstants.h.inl:51
constexpr VectorRegister4Float PiByFour
Definition UnrealMathVectorConstants.h.inl:124
constexpr VectorRegister4Float RAD_TO_DEG
Definition UnrealMathVectorConstants.h.inl:95
VectorRegister4Double DoubleAlmostTwo()
Definition UnrealMathVectorConstants.h.inl:157
constexpr VectorRegister4Double DoubleMinusOne
Definition UnrealMathVectorConstants.h.inl:60
constexpr VectorRegister4Double DOUBLE_QMULTI_SIGN_MASK2
Definition UnrealMathVectorConstants.h.inl:91
constexpr VectorRegister4Float KindaSmallNumber
Definition UnrealMathVectorConstants.h.inl:52
constexpr VectorRegister4Float BigNumber
Definition UnrealMathVectorConstants.h.inl:55
constexpr VectorRegister4Float QMULTI_SIGN_MASK0
Definition UnrealMathVectorConstants.h.inl:86
constexpr VectorRegister4Float OneOverPi
Definition UnrealMathVectorConstants.h.inl:125
constexpr VectorRegister4Float Float360
Definition UnrealMathVectorConstants.h.inl:138
constexpr VectorRegister4Double DoubleTwo
Definition UnrealMathVectorConstants.h.inl:155
constexpr VectorRegister4Float TwoPi
Definition UnrealMathVectorConstants.h.inl:122
constexpr VectorRegister4Float Float1000
Definition UnrealMathVectorConstants.h.inl:44
constexpr VectorRegister4Double Double360
Definition UnrealMathVectorConstants.h.inl:144
constexpr VectorRegister4Float QMULTI_SIGN_MASK1
Definition UnrealMathVectorConstants.h.inl:87
constexpr VectorRegister4Double DoubleSmallNumber
Definition UnrealMathVectorConstants.h.inl:71
constexpr VectorRegister4Int IntSignBit
Definition UnrealMathVectorConstants.h.inl:107
constexpr VectorRegister4Float PiByTwo
Definition UnrealMathVectorConstants.h.inl:123
constexpr uint64 DoubleAlmostTwoBits
Definition UnrealMathVectorConstants.h.inl:156
constexpr VectorRegister Vector0001
Definition UnrealMathVectorConstants.h.inl:75
constexpr VectorRegister4Float Float127
Definition UnrealMathVectorConstants.h.inl:136
constexpr VectorRegister4Double DoublePiByTwo
Definition UnrealMathVectorConstants.h.inl:130
constexpr VectorRegister4Double Double255
Definition UnrealMathVectorConstants.h.inl:141
constexpr VectorRegister4Float DEG_TO_RAD
Definition UnrealMathVectorConstants.h.inl:93
constexpr VectorRegister4Double DoubleBigNumber
Definition UnrealMathVectorConstants.h.inl:73
constexpr VectorRegister4Double DOUBLE_DEG_TO_RAD_HALF
Definition UnrealMathVectorConstants.h.inl:97
constexpr VectorRegister4Float Float111_Minus1
Definition UnrealMathVectorConstants.h.inl:48
constexpr VectorRegister4Double DOUBLE_QMULTI_SIGN_MASK0
Definition UnrealMathVectorConstants.h.inl:89
constexpr VectorRegister4Double DoubleOneOverTwoPi
Definition UnrealMathVectorConstants.h.inl:133
constexpr VectorRegister4Double DoubleMinusOneHalf
Definition UnrealMathVectorConstants.h.inl:69
constexpr VectorRegister4Float Float180
Definition UnrealMathVectorConstants.h.inl:139
constexpr VectorRegister4Float Pi
Definition UnrealMathVectorConstants.h.inl:121
constexpr VectorRegister4Float FloatMinus1_111
Definition UnrealMathVectorConstants.h.inl:49
VectorRegister4Double DoubleXYZMask()
Definition UnrealMathVectorConstants.h.inl:102
constexpr VectorRegister4Double DOUBLE_RAD_TO_DEG
Definition UnrealMathVectorConstants.h.inl:98
constexpr VectorRegister4Float QMULTI_SIGN_MASK2
Definition UnrealMathVectorConstants.h.inl:88
VectorRegister4Float AllMask()
Definition UnrealMathVectorConstants.h.inl:111
constexpr VectorRegister4Double DoublePi
Definition UnrealMathVectorConstants.h.inl:128
VectorRegister4Float SignMask()
Definition UnrealMathVectorConstants.h.inl:106
constexpr VectorRegister4Int IntOne
Definition UnrealMathVectorConstants.h.inl:78
constexpr VectorRegister4Float FloatOneHalf
Definition UnrealMathVectorConstants.h.inl:50
constexpr VectorRegister4Double DoubleSmallLengthThreshold
Definition UnrealMathVectorConstants.h.inl:64
constexpr VectorRegister4Double DoubleNonFractional
Definition UnrealMathVectorConstants.h.inl:149
VectorRegister4Double DoubleAllMask()
Definition UnrealMathVectorConstants.h.inl:112
constexpr VectorRegister4Float DEG_TO_RAD_HALF
Definition UnrealMathVectorConstants.h.inl:94
constexpr uint32 AlmostTwoBits
Definition UnrealMathVectorConstants.h.inl:152
constexpr VectorRegister4Double DoubleTwoPi
Definition UnrealMathVectorConstants.h.inl:129
constexpr VectorRegister4Double Double0001
Definition UnrealMathVectorConstants.h.inl:61
constexpr VectorRegister Vector1110
Definition UnrealMathVectorConstants.h.inl:76
constexpr VectorRegister4Double DoubleNeg127
Definition UnrealMathVectorConstants.h.inl:143
constexpr VectorRegister4Double DoubleKindaSmallNumber
Definition UnrealMathVectorConstants.h.inl:70
constexpr VectorRegister4Float FloatNonFractional
Definition UnrealMathVectorConstants.h.inl:148
constexpr VectorRegister4Float Float0001
Definition UnrealMathVectorConstants.h.inl:43
constexpr VectorRegister2Double DoubleOne2d
Definition UnrealMathVectorConstants.h.inl:57
constexpr VectorRegister4Double DoublePiByFour
Definition UnrealMathVectorConstants.h.inl:131
VectorRegister4Float FloatAlmostTwo()
Definition UnrealMathVectorConstants.h.inl:153
VectorRegister4Double DoubleInfinity()
Definition UnrealMathVectorConstants.h.inl:119
constexpr VectorRegister4Double Double1110
Definition UnrealMathVectorConstants.h.inl:63
constexpr VectorRegister4Double DoubleOneOverPi
Definition UnrealMathVectorConstants.h.inl:132
constexpr VectorRegister4Double DOUBLE_QMULTI_SIGN_MASK1
Definition UnrealMathVectorConstants.h.inl:90
constexpr VectorRegister4Double DOUBLE_QINV_SIGN_MASK
Definition UnrealMathVectorConstants.h.inl:84
VectorRegister4Float SignBit()
Definition UnrealMathVectorConstants.h.inl:105
constexpr VectorRegister4Float Float1110
Definition UnrealMathVectorConstants.h.inl:45
constexpr VectorRegister4Double DoubleOne
Definition UnrealMathVectorConstants.h.inl:58
constexpr VectorRegister4Float FloatOneHundredth
Definition UnrealMathVectorConstants.h.inl:47
VectorRegister4Float XYZMask()
Definition UnrealMathVectorConstants.h.inl:101
constexpr VectorRegister4Double DoubleZero
Definition UnrealMathVectorConstants.h.inl:59
constexpr VectorRegister4Double Double180
Definition UnrealMathVectorConstants.h.inl:145
Definition UnrealMathFPU.h:34
Definition UnrealMathFPU.h:42
Definition UnrealMathFPU.h:20
Definition UnrealMathFPU.h:28
Definition UnrealMathFPU.h:14