UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SpatialInterfaces.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3// Port of geometry3cpp SpatialInterfaces
4
5#pragma once
6
7#include "Math/Ray.h"
8#include "VectorTypes.h"
9
10namespace MeshIntersection
11{
18}
19
20namespace UE
21{
22namespace Geometry
23{
24
25
30{
31public:
32 virtual ~ISpatial() = default;
33
37 virtual bool SupportsPointContainment() const = 0;
38
42 virtual bool IsInside(const FVector3d & Point) const = 0;
43};
44
45
46
50class IMeshSpatial : public ISpatial
51{
52public:
53 virtual ~IMeshSpatial() = default;
54
55 // standard shared options for all mesh spatial queries
57 {
62
67
68 // If true, then the IMeshSpatial may allow queries even when the underlying mesh has been
69 // modified without updating the queried structure. This may be useful, for instance, to
70 // run queries against a mesh as it is being interactively modified, but it requires the
71 // caller to pass an appropriate TriangleFilterF to make sure that modified triangles do
72 // not affect the query.
74
78 };
79
83 virtual bool SupportsNearestTriangle() const = 0;
84
91 virtual int FindNearestTriangle(const FVector3d& Point, double& NearestDistSqrOut, const FQueryOptions& Options = FQueryOptions()) const = 0;
92
93
97 virtual bool SupportsTriangleRayIntersection() const = 0;
98
104 virtual int FindNearestHitTriangle(const FRay3d& Ray, const FQueryOptions& Options = FQueryOptions()) const
105 {
106 double NearestT;
107 int TID;
108 FindNearestHitTriangle(Ray, NearestT, TID, Options);
109 return TID;
110 }
111
120 virtual bool FindNearestHitTriangle(const FRay3d& Ray, double& NearestT, int& TID, const FQueryOptions& Options = FQueryOptions()) const
121 {
122 FVector3d BaryCoords;
123 return FindNearestHitTriangle(Ray, NearestT, TID, BaryCoords, Options);
124 }
125
135 virtual bool FindNearestHitTriangle(const FRay3d& Ray, double& NearestT, int& TID, FVector3d& BaryCoords, const FQueryOptions& Options = FQueryOptions()) const = 0;
136
144 virtual bool FindAllHitTriangles(const FRay3d& Ray, TArray<MeshIntersection::FHitIntersectionResult>& OutHits, const FQueryOptions& Options = FQueryOptions()) const = 0;
145};
146
147
148
153{
154public:
156
162 virtual FVector3d Project(const FVector3d& Point, int Identifier = -1) = 0;
163};
164
165
166
171{
172public:
174
180 virtual FVector3d Project(const FVector3d& Point, int Identifier = -1) override = 0;
181
189};
190
191
192
197{
198public:
200
204 virtual bool HasNormal() = 0;
205
212 virtual bool RayIntersect(const FRay3d& Ray, FVector3d& HitOut, FVector3d& HitNormalOut) = 0;
213};
214
215
216} // end namespace UE::Geometry
217} // end namespace UE
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
const bool
Definition NetworkReplayStreaming.h:178
Definition Array.h:670
Definition AndroidPlatformMisc.h:14
Definition SpatialInterfaces.h:197
virtual bool RayIntersect(const FRay3d &Ray, FVector3d &HitOut, FVector3d &HitNormalOut)=0
virtual ~IIntersectionTarget()
Definition SpatialInterfaces.h:199
Definition SpatialInterfaces.h:51
virtual bool FindNearestHitTriangle(const FRay3d &Ray, double &NearestT, int &TID, const FQueryOptions &Options=FQueryOptions()) const
Definition SpatialInterfaces.h:120
virtual ~IMeshSpatial()=default
virtual int FindNearestTriangle(const FVector3d &Point, double &NearestDistSqrOut, const FQueryOptions &Options=FQueryOptions()) const =0
virtual bool SupportsNearestTriangle() const =0
virtual bool SupportsTriangleRayIntersection() const =0
virtual bool FindNearestHitTriangle(const FRay3d &Ray, double &NearestT, int &TID, FVector3d &BaryCoords, const FQueryOptions &Options=FQueryOptions()) const =0
virtual int FindNearestHitTriangle(const FRay3d &Ray, const FQueryOptions &Options=FQueryOptions()) const
Definition SpatialInterfaces.h:104
virtual bool FindAllHitTriangles(const FRay3d &Ray, TArray< MeshIntersection::FHitIntersectionResult > &OutHits, const FQueryOptions &Options=FQueryOptions()) const =0
Definition SpatialInterfaces.h:171
virtual ~IOrientedProjectionTarget()
Definition SpatialInterfaces.h:173
virtual FVector3d Project(const FVector3d &Point, FVector3d &ProjectNormalOut, int Identifier=-1)=0
virtual FVector3d Project(const FVector3d &Point, int Identifier=-1) override=0
Definition SpatialInterfaces.h:153
virtual ~IProjectionTarget()
Definition SpatialInterfaces.h:155
virtual FVector3d Project(const FVector3d &Point, int Identifier=-1)=0
Definition SpatialInterfaces.h:30
virtual bool SupportsPointContainment() const =0
virtual ~ISpatial()=default
virtual bool IsInside(const FVector3d &Point) const =0
Definition MeshAABBTree3.h:17
Definition AdvancedWidgetsModule.cpp:13
Definition SpatialInterfaces.h:13
FVector3d BaryCoords
Definition SpatialInterfaces.h:16
double Distance
Definition SpatialInterfaces.h:15
int TriangleId
Definition SpatialInterfaces.h:14
Definition NumericLimits.h:41
Definition SpatialInterfaces.h:57
FQueryOptions(TFunction< bool(int)> TriangleFilterF)
Definition SpatialInterfaces.h:76
FQueryOptions(double MaxDistance, TFunction< bool(int)> TriangleFilterF=nullptr)
Definition SpatialInterfaces.h:77
FQueryOptions()
Definition SpatialInterfaces.h:75
double MaxDistance
Definition SpatialInterfaces.h:61
bool bAllowUnsafeModifiedMeshQueries
Definition SpatialInterfaces.h:73
TFunction< bool(int)> TriangleFilterF
Definition SpatialInterfaces.h:66