UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ContainmentQueries3.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "BoxTypes.h"
6#include "CapsuleTypes.h"
8#include "CoreMinimal.h"
9#include "HalfspaceTypes.h"
11#include "IntVectorTypes.h"
13#include "Math/UnrealMathSSE.h"
14#include "Math/Vector.h"
15#include "OrientedBoxTypes.h"
16#include "SphereTypes.h"
18#include "VectorTypes.h"
19
20
21namespace UE
22{
23 namespace Math { template <typename T> struct TTransform; }
24
25 namespace Geometry
26 {
27 template <class GridType, typename RealType, bool bScalarCellSize> class TTriLinearGridInterpolant;
28 template <typename T> struct TCapsule3;
29 template <typename T> struct THalfspace3;
30 template <typename T> struct TSphere3;
31 //
32 // Sphere Containment Queries
33 //
34
36 template<typename RealType>
38
40 template<typename RealType>
42
44 template<typename RealType>
46
50 {
52 {
53 if (OuterSphere.Contains(Point) == false)
54 {
55 return false;
56 }
57 }
58 return true;
59 }
60
62 template<typename RealType, typename GridType>
67
68
69
70 //
71 // Capsule Containment Queries
72 //
73
75 template<typename RealType>
77
79 template<typename RealType>
81
83 template<typename RealType>
85
89 {
91 {
92 if (OuterCapsule.Contains(Point) == false)
93 {
94 return false;
95 }
96 }
97 return true;
98 }
99
101 template<typename RealType, typename GridType>
106
107
108
109 //
110 // OrientedBox Containment Queries
111 //
112
114 template<typename RealType>
116
118 template<typename RealType>
120
122 template<typename RealType>
124
128 {
130 {
131 if (OuterBox.Contains(Point) == false)
132 {
133 return false;
134 }
135 }
136 return true;
137 }
138
140 template<typename RealType, typename GridType>
145
146
147 //
148 // Convex Hull/Volume containment queries
149 //
150
156 template<typename RealType>
158
164 template<typename RealType>
166
172 template<typename RealType>
174
182
183 template<typename RealType, typename GridType>
188
189
190 //
191 // Signed Distance Field containment queries
192 //
193
197 template<typename RealType, typename GridType>
199
203 template<typename RealType, typename GridType>
205
209 template<typename RealType, typename GridType>
211
217
221 template<typename RealType, typename GridType1, typename GridType2>
227
228
229 // Cylinder
230
234 template<typename RealType>
235 bool DoesCylinderContainPoint(const TVector<RealType>& CylinderCenter, const TVector<RealType>& NormalizedCylinderAxis,
236 RealType CylinderRadius, RealType CylindeHeight, const TVector<RealType>& QueryPoint);
237 }
238}
239
240
241
242template<typename RealType>
254
255
256template<typename RealType>
268
269
270template<typename RealType>
272{
274 {
276 {
277 return false;
278 }
279 }
280 return true;
281}
282
283
284template<typename RealType, typename EnumerablePointsType, typename E>
286{
288 {
290 {
291 if (Halfspace.Contains(Point))
292 {
293 return false;
294 }
295 }
296 }
297 return true;
298}
299
300
301
302namespace UE
303{
304 namespace Geometry
305 {
306 //
307 // Signed distance field containment tests
308 //
309 // To test if an object is inside an SDF, we first rasterize the object's AABB onto the SDF grid. If all of the AABB cells have negative SDF values,
310 // we report that the object is inside. Note this is conservative, not exact -- so an object may actually be inside the implicit surface defined by
311 // the SDF, but if its AABB is not fully inside then we will report "not inside."
312 //
313
314 template<typename RealType, typename GridType>
316 {
317 const FVector3i MinCell = OuterGrid.Cell(InnerAABB.Min);
319
320 for (int32 Dim = 0; Dim < 3; ++Dim)
321 {
322 if (MinCell[Dim] < 0 || MaxCell[Dim] >= OuterGrid.Dimensions[Dim])
323 {
324 return false; // AABB extends outside the grid
325 }
326 }
327
328 MaxCell += FVector3i(1, 1, 1);
329
330 for (int I = MinCell[0]; I < MaxCell[0]; ++I)
331 {
332 for (int J = MinCell[1]; J < MaxCell[1]; ++J)
333 {
334 for (int K = MinCell[2]; K < MaxCell[2]; ++K)
335 {
336 RealType GridCellValue = OuterGrid.Grid->GetValue(I, J, K);
337
338 if (GridCellValue >= 0) // one of the cells containing the AABB is outside the implicit surface
339 {
340 return false;
341 }
342 }
343 }
344 }
345
346 return true;
347 }
348
349 template<typename RealType, typename GridType>
362
363 template<typename RealType, typename GridType>
365 {
367 {
368 return OuterGridTransform.InverseTransformPosition(Corner);
369 });
370
372 }
373
374 template<typename RealType, typename GridType>
385
386 template<typename RealType, typename GridType, typename EnumerablePointsType, typename E>
397
398 }
399}
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
Definition ArrayView.h:139
Definition GridInterpolant.h:29
template bool GEOMETRYCORE_API TestIntersection(const TSegment2< float > &Segment, const TAxisAlignedBox2< float > &Box)
template bool GEOMETRYCORE_API DoesCylinderContainPoint(const TVector< float > &CylinderCenter, const TVector< float > &CylinderAxis, float CylinderRadius, float CylinderHeight, const TVector< float > &QueryPoint)
bool IsInsideHull(TArrayView< THalfspace3< RealType > > Halfspaces, const TSphere3< RealType > &InnerSphere)
Definition ContainmentQueries3.h:243
template bool GEOMETRYCORE_API IsInside(const TSphere3< float > &OuterSphere, const TSphere3< float > &InnerSphere)
Definition AdvancedWidgetsModule.cpp:13
Definition IntVectorTypes.h:252
Definition BoxTypes.h:247
void Contain(const TVector< RealType > &V)
Definition BoxTypes.h:438
Definition CapsuleTypes.h:24
Definition HalfspaceTypes.h:22
Definition OrientedBoxTypes.h:25
Definition SphereTypes.h:20
Definition TransformNonVectorized.h:39
Definition Vector.h:51