UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
IndexTypes.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "GeometryBase.h"
6#include "Math/IntVector.h"
8#include <limits>
9
10
12{
13 inline constexpr int InvalidID = -1;
14}
15
16namespace UE
17{
18namespace Geometry
19{
20
27{
28 union
29 {
30 struct
31 {
32 int A, B;
33 };
34
35 UE_DEPRECATED(all, "For internal use only")
37 };
38
39 constexpr FIndex2i() = default;
40 constexpr FIndex2i(int ValA, int ValB)
41 : A(ValA), B(ValB)
42 {}
43
44 constexpr static FIndex2i Zero()
45 {
46 return FIndex2i(0, 0);
47 }
48 constexpr static FIndex2i Max()
49 {
51 }
56
63 const int& operator[](int Idx) const
64 {
66 return AB[Idx];
68 }
69
70 inline bool operator==(const FIndex2i& Other) const
71 {
72 return A == Other.A && B == Other.B;
73 }
74
75 inline bool operator!=(const FIndex2i& Other) const
76 {
77 return A != Other.A || B != Other.B;
78 }
79
80 int IndexOf(int Value) const
81 {
82 return (A == Value) ? 0 : ((B == Value) ? 1 : -1);
83 }
84
85 bool Contains(int Value) const
86 {
87 return (A == Value) || (B == Value);
88 }
89
91 int OtherElement(int Value) const
92 {
93 if (A == Value)
94 {
95 return B;
96 }
97 else if (B == Value)
98 {
99 return A;
100 }
101 else
102 {
104 }
105 }
106
107 inline void Swap()
108 {
109 ::Swap(A, B);
110 }
111
112 inline void Sort()
113 {
114 if (A > B)
115 {
116 Swap();
117 }
118 }
119
128 {
129 I.Serialize(Ar);
130 return Ar;
131 }
132
135 {
136 Ar << A;
137 Ar << B;
138 }
139};
140
142{
143 // (this is how FIntVector and all the other FVectors do their hash functions)
144 // Note: this assumes there's no padding that could contain non compared data.
145 return FCrc::MemCrc_DEPRECATED(&Index, sizeof(FIndex2i));
146}
147
148
149
158{
159 union
160 {
161 struct
162 {
163 int A;
164 int B;
165 int C;
166 };
167
168 UE_DEPRECATED(all, "For internal use only")
170 };
171
172 constexpr FIndex3i() = default;
173 constexpr FIndex3i(int ValA, int ValB, int ValC)
174 : A(ValA), B(ValB), C(ValC)
175 {}
176
177 constexpr static FIndex3i Zero()
178 {
179 return FIndex3i(0, 0, 0);
180 }
189
196 const int& operator[](int Idx) const
197 {
199 return ABC[Idx];
201 }
202
203 bool operator==(const FIndex3i& Other) const
204 {
205 return A == Other.A && B == Other.B && C == Other.C;
206 }
207
208 bool operator!=(const FIndex3i& Other) const
209 {
210 return A != Other.A || B != Other.B || C != Other.C;
211 }
212
213 int IndexOf(int Value) const
214 {
215 return (A == Value) ? 0 : ((B == Value) ? 1 : (C == Value ? 2 : -1));
216 }
217
218 bool Contains(int Value) const
219 {
220 return (A == Value) || (B == Value) || (C == Value);
221 }
222
228
233 {
234 if (B == WantIndex0Value)
235 {
236 return FIndex3i(B, C, A);
237 }
238 else if (C == WantIndex0Value)
239 {
240 return FIndex3i(C, A, B);
241 }
242 return FIndex3i(A,B,C);
243 }
244
245
246
247 operator FIntVector() const
248 {
249 return FIntVector(A, B, C);
250 }
252 {
253 A = Vec.X;
254 B = Vec.Y;
255 C = Vec.Z;
256 }
257
266 {
267 I.Serialize(Ar);
268 return Ar;
269 }
270
273 {
274 Ar << A;
275 Ar << B;
276 Ar << C;
277 }
278};
279
281{
282 // (this is how FIntVector and all the other FVectors do their hash functions)
283 // Note: this assumes there's no padding that could contain uncompared data.
284 return FCrc::MemCrc_DEPRECATED(&Index, sizeof(FIndex3i));
285}
286
287
288
296{
297 union
298 {
299 struct
300 {
301 int A, B, C, D;
302 };
303
304 UE_DEPRECATED(all, "For internal use only")
305 int ABCD[4];
306 };
307
309 {
310 }
311 FIndex4i(int ValA, int ValB, int ValC, int ValD)
312 {
313 this->A = ValA;
314 this->B = ValB;
315 this->C = ValC;
316 this->D = ValD;
317 }
318
319 static FIndex4i Zero()
320 {
321 return FIndex4i(0, 0, 0, 0);
322 }
331
338 const int& operator[](int Idx) const
339 {
341 return ABCD[Idx];
343 }
344
345 bool operator==(const FIndex4i& Other) const
346 {
347 return A == Other.A && B == Other.B && C == Other.C && D == Other.D;
348 }
349
350 bool operator!=(const FIndex4i& Other) const
351 {
352 return A != Other.A || B != Other.B || C != Other.C || D != Other.D;
353 }
354
355 int IndexOf(int Value) const
356 {
357 return (A == Value) ? 0 : ((B == Value) ? 1 : ((C == Value) ? 2 : ((D == Value) ? 3 : -1)));
358 }
359
360 bool Contains(int Idx) const
361 {
362 return A == Idx || B == Idx || C == Idx || D == Idx;
363 }
364
373 {
374 I.Serialize(Ar);
375 return Ar;
376 }
377
380 {
381 Ar << A;
382 Ar << B;
383 Ar << C;
384 Ar << D;
385 }
386};
387
389{
390 // (this is how FIntVector and all the other FVectors do their hash functions)
391 // Note: this assumes there's no padding that could contain uncompared data.
392 return FCrc::MemCrc_DEPRECATED(&Index, sizeof(FIndex4i));
393}
394
395
396} // end namespace UE::Geometry
397} // end namespace UE
398
399template<> struct TCanBulkSerialize<UE::Geometry::FIndex2i> { enum { Value = true }; };
400template<> struct TCanBulkSerialize<UE::Geometry::FIndex3i> { enum { Value = true }; };
401template<> struct TCanBulkSerialize<UE::Geometry::FIndex4i> { enum { Value = true }; };
402
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
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
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
FInt32Vector3 FIntVector
Definition MathFwd.h:115
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Archive.h:1208
Definition IndexTypes.h:12
constexpr int InvalidID
Definition IndexTypes.h:13
uint32 GetTypeHash(const TBox< T > &Box)
Definition Box.h:1008
Definition AdvancedWidgetsModule.cpp:13
U16 Index
Definition radfft.cpp:71
static CORE_API uint32 MemCrc_DEPRECATED(const void *Data, int32 Length, uint32 CRC=0)
Definition Crc.cpp:592
Definition Array.h:45
Definition NumericLimits.h:41
Definition IndexTypes.h:27
constexpr FIndex2i()=default
int A
Definition IndexTypes.h:32
int AB[2]
Definition IndexTypes.h:36
bool Contains(int Value) const
Definition IndexTypes.h:85
void Swap()
Definition IndexTypes.h:107
int & operator[](int Idx)
Definition IndexTypes.h:57
static constexpr FIndex2i Invalid()
Definition IndexTypes.h:52
bool operator==(const FIndex2i &Other) const
Definition IndexTypes.h:70
int IndexOf(int Value) const
Definition IndexTypes.h:80
static constexpr FIndex2i Zero()
Definition IndexTypes.h:44
int B
Definition IndexTypes.h:32
friend FArchive & operator<<(FArchive &Ar, FIndex2i &I)
Definition IndexTypes.h:127
int OtherElement(int Value) const
Definition IndexTypes.h:91
static constexpr FIndex2i Max()
Definition IndexTypes.h:48
constexpr FIndex2i(int ValA, int ValB)
Definition IndexTypes.h:40
void Sort()
Definition IndexTypes.h:112
void Serialize(FArchive &Ar)
Definition IndexTypes.h:134
const int & operator[](int Idx) const
Definition IndexTypes.h:63
bool operator!=(const FIndex2i &Other) const
Definition IndexTypes.h:75
Definition IndexTypes.h:158
constexpr FIndex3i(int ValA, int ValB, int ValC)
Definition IndexTypes.h:173
static constexpr FIndex3i Zero()
Definition IndexTypes.h:177
int & operator[](int Idx)
Definition IndexTypes.h:190
void Serialize(FArchive &Ar)
Definition IndexTypes.h:272
friend FArchive & operator<<(FArchive &Ar, FIndex3i &I)
Definition IndexTypes.h:265
FIndex3i GetOffsetBy(int32 OffsetIndicesBy) const
Definition IndexTypes.h:224
bool operator==(const FIndex3i &Other) const
Definition IndexTypes.h:203
FIndex3i GetCycled(int32 WantIndex0Value) const
Definition IndexTypes.h:232
bool operator!=(const FIndex3i &Other) const
Definition IndexTypes.h:208
static constexpr FIndex3i Max()
Definition IndexTypes.h:181
constexpr FIndex3i()=default
int B
Definition IndexTypes.h:164
bool Contains(int Value) const
Definition IndexTypes.h:218
int A
Definition IndexTypes.h:163
int IndexOf(int Value) const
Definition IndexTypes.h:213
int ABC[3]
Definition IndexTypes.h:169
FIndex3i(const FIntVector &Vec)
Definition IndexTypes.h:251
const int & operator[](int Idx) const
Definition IndexTypes.h:196
int C
Definition IndexTypes.h:165
static constexpr FIndex3i Invalid()
Definition IndexTypes.h:185
Definition IndexTypes.h:296
static FIndex4i Zero()
Definition IndexTypes.h:319
static FIndex4i Invalid()
Definition IndexTypes.h:327
bool operator!=(const FIndex4i &Other) const
Definition IndexTypes.h:350
int ABCD[4]
Definition IndexTypes.h:305
int A
Definition IndexTypes.h:301
bool operator==(const FIndex4i &Other) const
Definition IndexTypes.h:345
int C
Definition IndexTypes.h:301
friend FArchive & operator<<(FArchive &Ar, FIndex4i &I)
Definition IndexTypes.h:372
int B
Definition IndexTypes.h:301
void Serialize(FArchive &Ar)
Definition IndexTypes.h:379
int D
Definition IndexTypes.h:301
static FIndex4i Max()
Definition IndexTypes.h:323
int IndexOf(int Value) const
Definition IndexTypes.h:355
const int & operator[](int Idx) const
Definition IndexTypes.h:338
FIndex4i(int ValA, int ValB, int ValC, int ValD)
Definition IndexTypes.h:311
int & operator[](int Idx)
Definition IndexTypes.h:332
FIndex4i()
Definition IndexTypes.h:308
bool Contains(int Idx) const
Definition IndexTypes.h:360