UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
IntBoxTypes.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "IntVectorTypes.h"
6
7namespace UE
8{
9namespace Geometry
10{
11
13{
16
19 {
20 }
21
22 FInterval1i(const int32& Min, const int32& Max)
23 {
24 this->Min = Min;
25 this->Max = Max;
26 }
27
32
33 int32 Center() const
34 {
35 return (Min + Max) / 2;
36 }
37
38 int32 Extent() const
39 {
40 return (Max - Min) / 2;
41 }
42 int32 Length() const
43 {
44 return Max - Min;
45 }
46
47 inline bool IsEmpty() const
48 {
49 return Max < Min;
50 }
51
52 void Expand(int32 Radius)
53 {
54 Max += Radius;
55 Min -= Radius;
56 }
57
58 void Contain(int32 V)
59 {
60 if (V < Min)
61 {
62 Min = V;
63 }
64 if (V > Max)
65 {
66 Max = V;
67 }
68 }
69};
70
71
72
73
75{
78
83
85 : Min(Min), Max(Max)
86 {
87 }
88
94 : Min((int32)0, (int32)0), Max(Width, Height)
95 {
96 }
97
104
106 {
107 return Max == Other.Max && Min == Other.Min;
108 }
110 {
111 return Max != Other.Max || Min != Other.Min;
112 }
113
120 {
121 check(Index >= 0 && Index <= 3);
122 int32 X = ((Index % 3) == 0) ? (Min.X) : (Max.X);
123 int32 Y = ((Index & 2) == 0) ? (Min.Y) : (Max.Y);
124 return FVector2i(X, Y);
125 }
126
127 inline bool IsEmpty() const
128 {
129 return Max.X < Min.X || Max.Y < Min.Y;
130 }
131
132 void Expand(int32 Radius)
133 {
134 Max.X += Radius;
135 Max.Y += Radius;
136 Min.X -= Radius;
137 Min.Y -= Radius;
138 }
139
140 int32 Area() const
141 {
144 return XLength * YLength;
145 }
146
148 {
149 return FVector2i(Max.X - Min.X, Max.Y - Min.Y);
150 }
151
152 bool Contains(const FVector2i& V) const
153 {
154 return (Min.X <= V.X) && (Min.Y <= V.Y) && (Max.X >= V.X) && (Max.Y >= V.Y);
155 }
156
157 void Contain(const FVector2i& V)
158 {
159 if (V.X < Min.X)
160 {
161 Min.X = V.X;
162 }
163 if (V.X > Max.X)
164 {
165 Max.X = V.X;
166 }
167 if (V.Y < Min.Y)
168 {
169 Min.Y = V.Y;
170 }
171 if (V.Y > Max.Y)
172 {
173 Max.Y = V.Y;
174 }
175 }
176};
177
178
179
180
181
182
184{
187
192
194 {
195 this->Min = Min;
196 this->Max = Max;
197 }
198
200 {
201 return Max == Other.Max && Min == Other.Min;
202 }
204 {
205 return Max != Other.Max || Min != Other.Min;
206 }
207
208 int32 Width() const
209 {
210 return TMathUtil<int32>::Max(Max.X - Min.X, 0);
211 }
212
213 int32 Height() const
214 {
215 return TMathUtil<int32>::Max(Max.Y - Min.Y, 0);
216 }
217
218 int32 Depth() const
219 {
220 return TMathUtil<int32>::Max(Max.Z - Min.Z, 0);
221 }
222
223 int32 Volume() const
224 {
225 return Width() * Height() * Depth();
226 }
227
229 {
230 return FVector3i(Max.X - Min.X, Max.Y - Min.Y, Max.Z - Min.Z);
231 }
232
233 bool Contains(const FVector3i& V) const
234 {
235 return (Min.X <= V.X) && (Min.Y <= V.Y) && (Min.Z <= V.Z) && (Max.X >= V.X) && (Max.Y >= V.Y) && (Max.Z >= V.Z);
236 }
237
238 void Contain(const FVector3i& V)
239 {
240 if (V.X < Min.X)
241 {
242 Min.X = V.X;
243 }
244 if (V.X > Max.X)
245 {
246 Max.X = V.X;
247 }
248 if (V.Y < Min.Y)
249 {
250 Min.Y = V.Y;
251 }
252 if (V.Y > Max.Y)
253 {
254 Max.Y = V.Y;
255 }
256 if (V.Z < Min.Z)
257 {
258 Min.Z = V.Z;
259 }
260 if (V.Z > Max.Z)
261 {
262 Max.Z = V.Z;
263 }
264 }
265
271 {
272 check(Index >= 0 && Index <= 7);
273 int32 X = (((Index & 1) != 0) ^ ((Index & 2) != 0)) ? (Max.X) : (Min.X);
274 int32 Y = ((Index / 2) % 2 == 0) ? (Min.Y) : (Max.Y);
275 int32 Z = (Index < 4) ? (Min.Z) : (Max.Z);
276 return FVector3i(X, Y, Z);
277 }
278
285
292};
293
294
295
296} // end namespace UE::Geometry
297} // end namespace UE
#define check(expr)
Definition AssertionMacros.h:314
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 X(Name, Desc)
Definition FormatStringSan.h:47
static RealType Max(const RealType A, const RealType B)
Definition MathUtil.h:246
Definition AdvancedWidgetsModule.cpp:13
U16 Index
Definition radfft.cpp:71
Definition NumericLimits.h:41
Definition IntBoxTypes.h:75
FAxisAlignedBox2i()
Definition IntBoxTypes.h:79
FVector2i Max
Definition IntBoxTypes.h:77
bool IsEmpty() const
Definition IntBoxTypes.h:127
static FAxisAlignedBox2i Empty()
Definition IntBoxTypes.h:98
FVector2i Min
Definition IntBoxTypes.h:76
bool operator!=(const FAxisAlignedBox2i &Other) const
Definition IntBoxTypes.h:109
FAxisAlignedBox2i(const FVector2i &Min, const FVector2i &Max)
Definition IntBoxTypes.h:84
FVector2i GetCorner(int Index) const
Definition IntBoxTypes.h:119
bool operator==(const FAxisAlignedBox2i &Other) const
Definition IntBoxTypes.h:105
bool Contains(const FVector2i &V) const
Definition IntBoxTypes.h:152
FVector2i Diagonal() const
Definition IntBoxTypes.h:147
FAxisAlignedBox2i(int32 SquareSize)
Definition IntBoxTypes.h:89
void Expand(int32 Radius)
Definition IntBoxTypes.h:132
FAxisAlignedBox2i(int32 Width, int32 Height)
Definition IntBoxTypes.h:93
void Contain(const FVector2i &V)
Definition IntBoxTypes.h:157
int32 Area() const
Definition IntBoxTypes.h:140
Definition IntBoxTypes.h:184
FVector3i Min
Definition IntBoxTypes.h:185
FAxisAlignedBox3i()
Definition IntBoxTypes.h:188
bool operator!=(const FAxisAlignedBox3i &Other) const
Definition IntBoxTypes.h:203
int32 Depth() const
Definition IntBoxTypes.h:218
static FAxisAlignedBox3i Empty()
Definition IntBoxTypes.h:279
int32 Volume() const
Definition IntBoxTypes.h:223
FAxisAlignedBox3i(const FVector3i &Min, const FVector3i &Max)
Definition IntBoxTypes.h:193
FVector3i GetCorner(int Index) const
Definition IntBoxTypes.h:270
int32 Height() const
Definition IntBoxTypes.h:213
int32 Width() const
Definition IntBoxTypes.h:208
FVector3i Max
Definition IntBoxTypes.h:186
void Contain(const FVector3i &V)
Definition IntBoxTypes.h:238
FVector3i Diagonal() const
Definition IntBoxTypes.h:228
static FAxisAlignedBox3i Infinite()
Definition IntBoxTypes.h:286
bool Contains(const FVector3i &V) const
Definition IntBoxTypes.h:233
bool operator==(const FAxisAlignedBox3i &Other) const
Definition IntBoxTypes.h:199
Definition IntBoxTypes.h:13
FInterval1i(const int32 &Min, const int32 &Max)
Definition IntBoxTypes.h:22
int32 Extent() const
Definition IntBoxTypes.h:38
FInterval1i()
Definition IntBoxTypes.h:17
int32 Max
Definition IntBoxTypes.h:15
int32 Center() const
Definition IntBoxTypes.h:33
void Contain(int32 V)
Definition IntBoxTypes.h:58
static FInterval1i Empty()
Definition IntBoxTypes.h:28
int32 Min
Definition IntBoxTypes.h:14
int32 Length() const
Definition IntBoxTypes.h:42
bool IsEmpty() const
Definition IntBoxTypes.h:47
void Expand(int32 Radius)
Definition IntBoxTypes.h:52
Definition IntVectorTypes.h:20
int32 X
Definition IntVectorTypes.h:25
int32 Y
Definition IntVectorTypes.h:25
Definition IntVectorTypes.h:252
int32 Z
Definition IntVectorTypes.h:257
int32 X
Definition IntVectorTypes.h:257
int32 Y
Definition IntVectorTypes.h:257