UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
IntVectorTypes.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Math/Vector.h"
6#include "Math/IntVector.h"
7#include "MathUtil.h"
8#include "VectorTypes.h"
9#include <sstream>
10
11
12namespace UE {
13namespace Geometry {
14
15
20{
21 union
22 {
23 struct
24 {
26 };
27
28 UE_DEPRECATED(all, "For internal use only")
29 int32 XY[2] = { {}, {} };
30 };
31
32 constexpr FVector2i()
33 : X(0), Y(0)
34 {
35 }
36
38 : X(ValX), Y(ValY)
39 {
40 }
41
42 constexpr FVector2i(const int32* Data)
43 : X(Data[0]), Y(Data[1])
44 {
45 }
46
48 constexpr FVector2i(const FVector2i& Vec) = default;
49 constexpr FVector2i& operator=(const FVector2i& V2) = default;
51
52 explicit constexpr operator const int32*() const
53 {
55 return XY;
57 };
58
59 explicit constexpr operator int32*()
60 {
62 return XY;
64 }
65
66 explicit operator FVector2f() const
67 {
68 return FVector2f((float)X, (float)Y);
69 }
70 explicit operator FVector2d() const
71 {
72 return FVector2d((double)X, (double)Y);
73 }
74 explicit operator FIntVector2() const
75 {
76 return FIntVector2(X, Y);
77 }
78
79 explicit FVector2i(const FVector& Vec)
80 : X((int32)Vec.X), Y((int32)Vec.Y)
81 {
82 }
83
84 explicit FVector2i(const FVector2f& Vec)
85 : X((int32)Vec.X), Y((int32)Vec.Y)
86 {
87 }
88
89 explicit FVector2i(const FVector2d& Vec)
90 : X((int32)Vec.X), Y((int32)Vec.Y)
91 {
92 }
93
94 explicit FVector2i(const FIntVector2& Vec)
95 : X(Vec.X), Y(Vec.Y)
96 {
97 }
98
99 constexpr static FVector2i Zero()
100 {
101 return FVector2i(0, 0);
102 }
103 constexpr static FVector2i One()
104 {
105 return FVector2i(1, 1);
106 }
107 constexpr static FVector2i UnitX()
108 {
109 return FVector2i(1, 0);
110 }
111 constexpr static FVector2i UnitY()
112 {
113 return FVector2i(0, 1);
114 }
115
116 constexpr int32& operator[](int Idx)
117 {
119 return XY[Idx];
121 }
122 constexpr const int32& operator[](int Idx) const
123 {
125 return XY[Idx];
127 }
128
129 constexpr int32 SquaredLength() const
130 {
131 return X * X + Y * Y;
132 }
133
134 constexpr int32 DistanceSquared(const FVector2i& V2) const
135 {
136 int32 dx = V2.X - X;
137 int32 dy = V2.Y - Y;
138 return dx * dx + dy * dy;
139 }
140
141 constexpr int32 Dot(const FVector2i& V2) const
142 {
143 return X * V2.X + Y * V2.Y;
144 }
145
146 constexpr FVector2i operator-() const
147 {
148 return FVector2i(-X, -Y);
149 }
150
151 constexpr FVector2i operator+(const FVector2i& V2) const
152 {
153 return FVector2i(X + V2.X, Y + V2.Y);
154 }
155
156 constexpr FVector2i operator-(const FVector2i& V2) const
157 {
158 return FVector2i(X - V2.X, Y - V2.Y);
159 }
160
161 constexpr FVector2i operator+(const int32& Scalar) const
162 {
163 return FVector2i(X + Scalar, Y + Scalar);
164 }
165
166 constexpr FVector2i operator-(const int32& Scalar) const
167 {
168 return FVector2i(X - Scalar, Y - Scalar);
169 }
170
171 constexpr FVector2i operator*(const int32& Scalar) const
172 {
173 return FVector2i(X * Scalar, Y * Scalar);
174 }
175
176 constexpr FVector2i operator*(const FVector2i& V2) const // component-wise
177 {
178 return FVector2i(X * V2.X, Y * V2.Y);
179 }
180
181 constexpr FVector2i operator/(const int32& Scalar) const
182 {
183 return FVector2i(X / Scalar, Y / Scalar);
184 }
185
186 constexpr FVector2i operator/(const FVector2i& V2) const // component-wise
187 {
188 return FVector2i(X / V2.X, Y / V2.Y);
189 }
190
191 constexpr FVector2i& operator+=(const FVector2i& V2)
192 {
193 X += V2.X;
194 Y += V2.Y;
195 return *this;
196 }
197
198 constexpr FVector2i& operator-=(const FVector2i& V2)
199 {
200 X -= V2.X;
201 Y -= V2.Y;
202 return *this;
203 }
204
205 constexpr FVector2i& operator*=(const int32& Scalar)
206 {
207 X *= Scalar;
208 Y *= Scalar;
209 return *this;
210 }
211
212 constexpr FVector2i& operator/=(const int32& Scalar)
213 {
214 X /= Scalar;
215 Y /= Scalar;
216 return *this;
217 }
218
219 constexpr bool operator==(const FVector2i& Other) const
220 {
221 return X == Other.X && Y == Other.Y;
222 }
223
224 constexpr bool operator!=(const FVector2i& Other) const
225 {
226 return X != Other.X || Y != Other.Y;
227 }
228};
229
231{
232 return FVector2i(Scalar * V.X, Scalar * V.Y);
233}
234
235inline std::ostream& operator<<(std::ostream& os, const FVector2i& Vec)
236{
237 os << Vec.X << " " << Vec.Y;
238 return os;
239}
240
242{
243 return FCrc::MemCrc_DEPRECATED(&Vector, sizeof(FVector2i));
244}
245
246
247
252{
253 union
254 {
255 struct
256 {
258 };
259
260 UE_DEPRECATED(all, "For internal use only")
261 int32 XYZ[3] = { {}, {}, {} };
262 };
263
264 constexpr FVector3i()
265 : X(0), Y(0), Z(0)
266 {
267 }
268
270 : X(ValX), Y(ValY), Z(ValZ)
271 {
272 }
273
274 constexpr FVector3i(const int32* Data)
275 : X(Data[0]), Y(Data[1]), Z(Data[2])
276 {
277 }
278
280 constexpr FVector3i(const FVector3i& Vec) = default;
281 FVector3i& operator=(const FVector3i& V2) = default;
283
284 explicit constexpr operator const int32*() const
285 {
287 return XYZ;
289 };
290 explicit constexpr operator int32*()
291 {
293 return XYZ;
295 }
296
297 explicit operator FVector3f() const
298 {
299 return FVector3f((float)X, (float)Y, (float)Z);
300 }
301 explicit operator FVector3d() const
302 {
303 return FVector3d((double)X, (double)Y, (double)Z);
304 }
305
306 explicit operator FIntVector() const
307 {
308 return FIntVector(X, Y, Z);
309 }
310
311 explicit FVector3i(const FVector3f& Vec)
312 : X((int32)Vec.X), Y((int32)Vec.Y), Z((int32)Vec.Z)
313 {
314 }
315
316 explicit FVector3i(const FVector3d& Vec)
317 : X((int32)Vec.X), Y((int32)Vec.Y), Z((int32)Vec.Z)
318 {
319 }
320
321 explicit FVector3i(const FIntVector& Vec)
322 : X(Vec.X), Y(Vec.Y), Z(Vec.Z)
323 {
324 }
325
327 {
328 return FVector3i(0, 0, 0);
329 }
330 static FVector3i One()
331 {
332 return FVector3i(1, 1, 1);
333 }
335 {
336 return FVector3i(1, 0, 0);
337 }
339 {
340 return FVector3i(0, 1, 0);
341 }
343 {
344 return FVector3i(0, 0, 1);
345 }
350
357 const int32& operator[](int Idx) const
358 {
360 return XYZ[Idx];
362 }
363
364 constexpr int32 SquaredLength() const
365 {
366 return X * X + Y * Y + Z * Z;
367 }
368
369 constexpr int32 DistanceSquared(const FVector3i& V2) const
370 {
371 int32 dx = V2.X - X;
372 int32 dy = V2.Y - Y;
373 int32 dz = V2.Z - Z;
374 return dx * dx + dy * dy + dz * dz;
375 }
376
377 constexpr FVector3i operator-() const
378 {
379 return FVector3i(-X, -Y, -Z);
380 }
381
382 constexpr FVector3i operator+(const FVector3i& V2) const
383 {
384 return FVector3i(X + V2.X, Y + V2.Y, Z + V2.Z);
385 }
386
387 constexpr FVector3i operator-(const FVector3i& V2) const
388 {
389 return FVector3i(X - V2.X, Y - V2.Y, Z - V2.Z);
390 }
391
392 constexpr FVector3i operator+(const int32& Scalar) const
393 {
394 return FVector3i(X + Scalar, Y + Scalar, Z + Scalar);
395 }
396
397 constexpr FVector3i operator-(const int32& Scalar) const
398 {
399 return FVector3i(X - Scalar, Y - Scalar, Z - Scalar);
400 }
401
402 constexpr FVector3i operator*(const int32& Scalar) const
403 {
404 return FVector3i(X * Scalar, Y * Scalar, Z * Scalar);
405 }
406
407 constexpr FVector3i operator*(const FVector3i& V2) const // component-wise
408 {
409 return FVector3i(X * V2.X, Y * V2.Y, Z * V2.Z);
410 }
411
412 constexpr FVector3i operator/(const int32& Scalar) const
413 {
414 return FVector3i(X / Scalar, Y / Scalar, Z / Scalar);
415 }
416
417 constexpr FVector3i operator/(const FVector3i& V2) const // component-wise
418 {
419 return FVector3i(X / V2.X, Y / V2.Y, Z / V2.Z);
420 }
421
422 constexpr FVector3i& operator+=(const FVector3i& V2)
423 {
424 X += V2.X;
425 Y += V2.Y;
426 Z += V2.Z;
427 return *this;
428 }
429
430 constexpr FVector3i& operator-=(const FVector3i& V2)
431 {
432 X -= V2.X;
433 Y -= V2.Y;
434 Z -= V2.Z;
435 return *this;
436 }
437
438 constexpr FVector3i& operator*=(const int32& Scalar)
439 {
440 X *= Scalar;
441 Y *= Scalar;
442 Z *= Scalar;
443 return *this;
444 }
445
446 constexpr FVector3i& operator/=(const int32& Scalar)
447 {
448 X /= Scalar;
449 Y /= Scalar;
450 Z /= Scalar;
451 return *this;
452 }
453
454 constexpr int32 Dot(const FVector3i& V2) const
455 {
456 return X * V2.X + Y * V2.Y + Z * V2.Z;
457 }
458
459 constexpr bool operator==(const FVector3i& Other) const
460 {
461 return X == Other.X && Y == Other.Y && Z == Other.Z;
462 }
463
464 constexpr bool operator!=(const FVector3i& Other) const
465 {
466 return X != Other.X || Y != Other.Y || Z != Other.Z;
467 }
468
469 constexpr bool operator<(const FVector3i& Other) const
470 {
471 if ( X != Other.X ) return X < Other.X;
472 else if (Y != Other.Y) return Y < Other.Y;
473 else if (Z != Other.Z) return Z < Other.Z;
474 else return false;
475 }
476};
477
478
480{
481 return FVector3i(Scalar * V.X, Scalar * V.Y, Scalar * V.Z);
482}
483
484
485inline FVector3i Min(const FVector3i& V0, const FVector3i& V1)
486{
487 return FVector3i(TMathUtil<int32>::Min(V0.X, V1.X),
488 TMathUtil<int32>::Min(V0.Y, V1.Y),
489 TMathUtil<int32>::Min(V0.Z, V1.Z));
490}
491
492inline FVector3i Max(const FVector3i& V0, const FVector3i& V1)
493{
494 return FVector3i(TMathUtil<int32>::Max(V0.X, V1.X),
495 TMathUtil<int32>::Max(V0.Y, V1.Y),
496 TMathUtil<int32>::Max(V0.Z, V1.Z));
497}
498
499
500
501inline std::ostream& operator<<(std::ostream& os, const FVector3i& Vec)
502{
503 os << Vec.X << " " << Vec.Y << " " << Vec.Z;
504 return os;
505}
506
508{
509 return FCrc::MemCrc_DEPRECATED(&Vector, sizeof(FVector3i));
510}
511
512
513
514} // end namespace UE::Geometry
515} // end namespace UE
516
517
#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
UE::Math::TVector2< float > FVector2f
Definition MathFwd.h:74
UE::Math::TIntVector2< int32 > FIntVector2
Definition MathFwd.h:91
UE::Math::TVector< float > FVector3f
Definition MathFwd.h:73
UE::Math::TVector2< double > FVector2d
Definition MathFwd.h:61
UE::Math::TVector< double > FVector3d
Definition MathFwd.h:60
FInt32Vector3 FIntVector
Definition MathFwd.h:115
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition MathUtil.h:150
uint32 GetTypeHash(const TBox< T > &Box)
Definition Box.h:1008
FArchive & operator<<(FArchive &Ar, TBoxSphereBounds< float, float > &Bounds)
Definition BoxSphereBounds.h:396
UE_FORCEINLINE_HINT TQuat< T > operator*(const float Scale, const TQuat< T > &Q)
Definition Quat.h:1055
Definition AdvancedWidgetsModule.cpp:13
static CORE_API uint32 MemCrc_DEPRECATED(const void *Data, int32 Length, uint32 CRC=0)
Definition Crc.cpp:592
Definition NumericLimits.h:41
Definition IntVectorTypes.h:20
constexpr int32 Dot(const FVector2i &V2) const
Definition IntVectorTypes.h:141
int32 X
Definition IntVectorTypes.h:25
constexpr FVector2i(int32 ValX, int32 ValY)
Definition IntVectorTypes.h:37
constexpr FVector2i operator-(const FVector2i &V2) const
Definition IntVectorTypes.h:156
static constexpr FVector2i UnitX()
Definition IntVectorTypes.h:107
constexpr FVector2i & operator+=(const FVector2i &V2)
Definition IntVectorTypes.h:191
constexpr int32 & operator[](int Idx)
Definition IntVectorTypes.h:116
constexpr bool operator==(const FVector2i &Other) const
Definition IntVectorTypes.h:219
static constexpr FVector2i UnitY()
Definition IntVectorTypes.h:111
PRAGMA_DISABLE_DEPRECATION_WARNINGS constexpr FVector2i(const FVector2i &Vec)=default
constexpr FVector2i & operator/=(const int32 &Scalar)
Definition IntVectorTypes.h:212
constexpr FVector2i operator*(const FVector2i &V2) const
Definition IntVectorTypes.h:176
constexpr FVector2i operator-(const int32 &Scalar) const
Definition IntVectorTypes.h:166
constexpr FVector2i operator/(const int32 &Scalar) const
Definition IntVectorTypes.h:181
constexpr int32 DistanceSquared(const FVector2i &V2) const
Definition IntVectorTypes.h:134
constexpr FVector2i operator+(const FVector2i &V2) const
Definition IntVectorTypes.h:151
constexpr FVector2i operator+(const int32 &Scalar) const
Definition IntVectorTypes.h:161
constexpr bool operator!=(const FVector2i &Other) const
Definition IntVectorTypes.h:224
FVector2i(const FVector2f &Vec)
Definition IntVectorTypes.h:84
int32 XY[2]
Definition IntVectorTypes.h:29
constexpr FVector2i & operator-=(const FVector2i &V2)
Definition IntVectorTypes.h:198
constexpr FVector2i operator/(const FVector2i &V2) const
Definition IntVectorTypes.h:186
constexpr const int32 & operator[](int Idx) const
Definition IntVectorTypes.h:122
int32 Y
Definition IntVectorTypes.h:25
FVector2i(const FVector &Vec)
Definition IntVectorTypes.h:79
constexpr FVector2i & operator*=(const int32 &Scalar)
Definition IntVectorTypes.h:205
FVector2i(const FIntVector2 &Vec)
Definition IntVectorTypes.h:94
constexpr FVector2i & operator=(const FVector2i &V2)=default
constexpr int32 SquaredLength() const
Definition IntVectorTypes.h:129
constexpr FVector2i(const int32 *Data)
Definition IntVectorTypes.h:42
constexpr FVector2i()
Definition IntVectorTypes.h:32
FVector2i(const FVector2d &Vec)
Definition IntVectorTypes.h:89
static constexpr FVector2i Zero()
Definition IntVectorTypes.h:99
constexpr FVector2i operator*(const int32 &Scalar) const
Definition IntVectorTypes.h:171
static constexpr FVector2i One()
Definition IntVectorTypes.h:103
constexpr FVector2i operator-() const
Definition IntVectorTypes.h:146
Definition IntVectorTypes.h:252
FVector3i(const FIntVector &Vec)
Definition IntVectorTypes.h:321
static FVector3i UnitY()
Definition IntVectorTypes.h:338
static FVector3i One()
Definition IntVectorTypes.h:330
static FVector3i UnitX()
Definition IntVectorTypes.h:334
int32 & operator[](int Idx)
Definition IntVectorTypes.h:351
constexpr int32 SquaredLength() const
Definition IntVectorTypes.h:364
static FVector3i Zero()
Definition IntVectorTypes.h:326
constexpr FVector3i operator+(const FVector3i &V2) const
Definition IntVectorTypes.h:382
constexpr int32 DistanceSquared(const FVector3i &V2) const
Definition IntVectorTypes.h:369
int32 Z
Definition IntVectorTypes.h:257
FVector3i & operator=(const FVector3i &V2)=default
constexpr bool operator==(const FVector3i &Other) const
Definition IntVectorTypes.h:459
PRAGMA_DISABLE_DEPRECATION_WARNINGS constexpr FVector3i(const FVector3i &Vec)=default
constexpr FVector3i & operator+=(const FVector3i &V2)
Definition IntVectorTypes.h:422
constexpr FVector3i operator-(const int32 &Scalar) const
Definition IntVectorTypes.h:397
int32 XYZ[3]
Definition IntVectorTypes.h:261
constexpr FVector3i & operator*=(const int32 &Scalar)
Definition IntVectorTypes.h:438
constexpr FVector3i operator+(const int32 &Scalar) const
Definition IntVectorTypes.h:392
int32 X
Definition IntVectorTypes.h:257
static FVector3i UnitZ()
Definition IntVectorTypes.h:342
constexpr bool operator!=(const FVector3i &Other) const
Definition IntVectorTypes.h:464
const int32 & operator[](int Idx) const
Definition IntVectorTypes.h:357
constexpr FVector3i operator*(const int32 &Scalar) const
Definition IntVectorTypes.h:402
FVector3i(const FVector3d &Vec)
Definition IntVectorTypes.h:316
constexpr FVector3i(int32 ValX, int32 ValY, int32 ValZ)
Definition IntVectorTypes.h:269
int32 Y
Definition IntVectorTypes.h:257
constexpr FVector3i operator*(const FVector3i &V2) const
Definition IntVectorTypes.h:407
constexpr FVector3i(const int32 *Data)
Definition IntVectorTypes.h:274
static FVector3i MaxVector()
Definition IntVectorTypes.h:346
constexpr FVector3i operator/(const FVector3i &V2) const
Definition IntVectorTypes.h:417
constexpr FVector3i & operator-=(const FVector3i &V2)
Definition IntVectorTypes.h:430
constexpr FVector3i operator/(const int32 &Scalar) const
Definition IntVectorTypes.h:412
FVector3i(const FVector3f &Vec)
Definition IntVectorTypes.h:311
constexpr FVector3i operator-(const FVector3i &V2) const
Definition IntVectorTypes.h:387
constexpr bool operator<(const FVector3i &Other) const
Definition IntVectorTypes.h:469
constexpr FVector3i operator-() const
Definition IntVectorTypes.h:377
constexpr int32 Dot(const FVector3i &V2) const
Definition IntVectorTypes.h:454
constexpr FVector3i()
Definition IntVectorTypes.h:264
constexpr FVector3i & operator/=(const int32 &Scalar)
Definition IntVectorTypes.h:446