UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE::Geometry::TMeshQueries< TriangleMeshType > Class Template Reference

#include <MeshQueries.h>

Public Member Functions

 TMeshQueries ()=delete
 

Static Public Member Functions

static FDistPoint3Triangle3d TriangleDistance (const TriangleMeshType &Mesh, int TriIdx, FVector3d Point)
 
static FIntrRay3Triangle3d TriangleIntersection (const TriangleMeshType &Mesh, int TriIdx, const FRay3d &Ray)
 
static FVector3d GetTriCentroid (const TriangleMeshType &Mesh, int TriIdx)
 
static void GetTriNormalAreaCentroid (const TriangleMeshType &Mesh, int TriIdx, FVector3d &Normal, double &Area, FVector3d &Centroid)
 
static FVector3d GetMeshVerticesCentroid (const TriangleMeshType &Mesh)
 
static double GetVolumeNonWatertight (const TriangleMeshType &Mesh, double DimScaleFactor=1)
 
static FVector2d GetVolumeArea (const TriangleMeshType &Mesh)
 
static FVector2d GetVolumeAreaCenter (const TriangleMeshType &Mesh, FVector3d &OutCenterOfMass)
 
static FVector2d GetVolumeArea (const TriangleMeshType &Mesh, const TArray< int > &TriIndices)
 
static FAxisAlignedBox3d GetTriBounds (const TriangleMeshType &Mesh, int TID)
 
static FAxisAlignedBox3d GetBounds (const TriangleMeshType &Mesh)
 
template<typename EnumerableTriListType >
static FAxisAlignedBox3d GetTrianglesBounds (const TriangleMeshType &Mesh, const EnumerableTriListType &Triangles, const FTransform &Transform=FTransform::Identity)
 
template<typename EnumerableTriListType >
static FAxisAlignedBox3d GetVerticesBounds (const TriangleMeshType &Mesh, const EnumerableTriListType &Vertices, const FTransform &Transform=FTransform::Identity)
 
static int FindNearestTriangle_LinearSearch (const TriangleMeshType &Mesh, const FVector3d &P)
 
static FVector3d FindNearestPoint_LinearSearch (const TriangleMeshType &Mesh, const FVector3d &P)
 
static double TriDistanceSqr (const TriangleMeshType &Mesh, int TriIdx, const FVector3d &Point)
 
static int FindHitTriangle_LinearSearch (const TriangleMeshType &Mesh, const FRay3d &Ray)
 
static void FindHitTriangles_LinearSearch (const TriangleMeshType &Mesh, const FRay3d &Ray, TArray< TPair< float, int > > &SortedHitTriangles)
 
static FIndex2i FindIntersectingTriangles_LinearSearch (const TriangleMeshType &Mesh1, const TriangleMeshType &Mesh2)
 
template<typename RayType = FRay3d>
static FIntrRay3Triangle3d RayTriangleIntersection (const TriangleMeshType &Mesh, int TriIdx, const RayType &Ray)
 
static void GetAllEdgeLengths (const TriangleMeshType &Mesh, TArray< double > &Lengths, double &TotalLength)
 
static double AverageEdgeLength (const TriangleMeshType &Mesh)
 Compute the mean edge length for the given mesh.
 
static double MaxEdgeLength (const TriangleMeshType &Mesh)
 Compute the longest edge length for the given mesh.
 
static double MinEdgeLength (const TriangleMeshType &Mesh)
 Compute the shortest edge length for the given mesh.
 
static double TotalEdgeLength (const TriangleMeshType &Mesh, const TArray< int > &Edges)
 Given a mesh and a subset of mesh edges, compute the total length of all the edges.
 
static void EdgeLengthStatsFromEdges (const TriangleMeshType &Mesh, const TArray< int > &Edges, double &MinEdgeLength, double &MaxEdgeLength, double &AverageEdgeLength)
 Given a mesh and a subset of mesh edges, compute the min, max, and mean edge lengths.
 
static void EdgeLengthStats (const TriangleMeshType &Mesh, double &MinEdgeLength, double &MaxEdgeLength, double &AverageEdgeLength, int NumSamples=0)
 
template<typename MeshSpatialType >
static void VertexToSurfaceDistances (const TriangleMeshType &MeshA, const MeshSpatialType &SpatialB, TArray< double > &Distances)
 
template<typename MeshSpatialType >
static double HausdorffDistance (const TriangleMeshType &MeshA, const MeshSpatialType &SpatialB)
 
template<typename MeshSpatialType >
static double TwoSidedHausdorffDistance (const TriangleMeshType &MeshA, const MeshSpatialType &SpatialA, const TriangleMeshType &MeshB, const MeshSpatialType &SpatialB)
 Because Hausdorff distance is not symmetric, we compute the maximum of the distances between two surfaces.
 
template<typename MeshSpatialType >
static void VertexToSurfaceDistancesSerial (const TriangleMeshType &MeshA, const MeshSpatialType &SpatialB, TArray< double > &Distances)
 Compute all vertex-to-surface distances in serial. Should only be used for debugging the parallel version above!
 
template<typename MeshSpatialType >
static double HausdorffDistanceSerial (const TriangleMeshType &MeshA, const MeshSpatialType &SpatialB)
 
template<typename MeshSpatialType >
static double TwoSidedHausdorffDistanceSerial (const TriangleMeshType &MeshA, const MeshSpatialType &SpatialA, const TriangleMeshType &MeshB, const MeshSpatialType &SpatialB)
 
template<typename MeshSpatialType >
static void MeshDistanceStatistics (const TriangleMeshType &MeshA, const MeshSpatialType &SpatialB, const TriangleMeshType *MeshB, const MeshSpatialType *SpatialA, bool bSymmetric, double &MaxDistance, double &MinDistance, double &AverageDistance, double &RootMeanSqrDeviation)
 
static FVector3d GetVertexWeightsOnTriangle (const TriangleMeshType &Mesh, int TriID, double TriArea, bool bWeightByArea, bool bWeightByAngle)
 
static TArray< int32GetVertexSelectedTriangles (const TriangleMeshType &Mesh, const TArray< int32 > &Vertices)
 
static void ExpandVertexSelectionToNeighbors (const TriangleMeshType &Mesh, const TArray< int32 > &Selection, TArray< int32 > &ExpandedSelection, TMap< int32, int32 > &VIDToExpandedSelectionIdx)
 

Constructor & Destructor Documentation

◆ TMeshQueries()

template<class TriangleMeshType >
UE::Geometry::TMeshQueries< TriangleMeshType >::TMeshQueries ( )
delete

Member Function Documentation

◆ AverageEdgeLength()

template<class TriangleMeshType >
static double UE::Geometry::TMeshQueries< TriangleMeshType >::AverageEdgeLength ( const TriangleMeshType Mesh)
inlinestatic

Compute the mean edge length for the given mesh.

◆ EdgeLengthStats()

template<class TriangleMeshType >
static void UE::Geometry::TMeshQueries< TriangleMeshType >::EdgeLengthStats ( const TriangleMeshType Mesh,
double MinEdgeLength,
double MaxEdgeLength,
double AverageEdgeLength,
int  NumSamples = 0 
)
inlinestatic

Compute the min, max, and mean edge lengths for the given mesh. Optionally, choose a subest of size NumSamples and compute stats of that subset.

◆ EdgeLengthStatsFromEdges()

template<class TriangleMeshType >
static void UE::Geometry::TMeshQueries< TriangleMeshType >::EdgeLengthStatsFromEdges ( const TriangleMeshType Mesh,
const TArray< int > &  Edges,
double MinEdgeLength,
double MaxEdgeLength,
double AverageEdgeLength 
)
inlinestatic

Given a mesh and a subset of mesh edges, compute the min, max, and mean edge lengths.

◆ ExpandVertexSelectionToNeighbors()

template<class TriangleMeshType >
static void UE::Geometry::TMeshQueries< TriangleMeshType >::ExpandVertexSelectionToNeighbors ( const TriangleMeshType Mesh,
const TArray< int32 > &  Selection,
TArray< int32 > &  ExpandedSelection,
TMap< int32, int32 > &  VIDToExpandedSelectionIdx 
)
inlinestatic

Expand selection of vertices with one-ring neighbors.

Parameters
SelectionArray of Mesh vertex IDs.
ExpandedSelectionAll vertices in Selection plus one-ring neighbors for each vertex.
VIDToExpandedSelectionIdxMaps mesh Vertex ID to ExpandedSelection array index.

◆ FindHitTriangle_LinearSearch()

template<class TriangleMeshType >
static int UE::Geometry::TMeshQueries< TriangleMeshType >::FindHitTriangle_LinearSearch ( const TriangleMeshType Mesh,
const FRay3d Ray 
)
inlinestatic

◆ FindHitTriangles_LinearSearch()

template<class TriangleMeshType >
static void UE::Geometry::TMeshQueries< TriangleMeshType >::FindHitTriangles_LinearSearch ( const TriangleMeshType Mesh,
const FRay3d Ray,
TArray< TPair< float, int > > &  SortedHitTriangles 
)
inlinestatic

◆ FindIntersectingTriangles_LinearSearch()

template<class TriangleMeshType >
static FIndex2i UE::Geometry::TMeshQueries< TriangleMeshType >::FindIntersectingTriangles_LinearSearch ( const TriangleMeshType Mesh1,
const TriangleMeshType Mesh2 
)
inlinestatic

brute force search for any intersecting triangles on two meshes

Returns
Index pair of IDs of first intersecting triangles found, or InvalidID if no intersection found

◆ FindNearestPoint_LinearSearch()

template<class TriangleMeshType >
static FVector3d UE::Geometry::TMeshQueries< TriangleMeshType >::FindNearestPoint_LinearSearch ( const TriangleMeshType Mesh,
const FVector3d P 
)
inlinestatic
Returns
nearest point on Mesh to P, or P if nearest point was not found

◆ FindNearestTriangle_LinearSearch()

template<class TriangleMeshType >
static int UE::Geometry::TMeshQueries< TriangleMeshType >::FindNearestTriangle_LinearSearch ( const TriangleMeshType Mesh,
const FVector3d P 
)
inlinestatic

◆ GetAllEdgeLengths()

template<class TriangleMeshType >
static void UE::Geometry::TMeshQueries< TriangleMeshType >::GetAllEdgeLengths ( const TriangleMeshType Mesh,
TArray< double > &  Lengths,
double TotalLength 
)
inlinestatic

Compute the length for each edge and return the result as an array of Mesh.MaxEdgeID() size. When mesh is not compact, the length of the missing edges is set to -1.0

◆ GetBounds()

template<class TriangleMeshType >
static FAxisAlignedBox3d UE::Geometry::TMeshQueries< TriangleMeshType >::GetBounds ( const TriangleMeshType Mesh)
inlinestatic

◆ GetMeshVerticesCentroid()

template<class TriangleMeshType >
static FVector3d UE::Geometry::TMeshQueries< TriangleMeshType >::GetMeshVerticesCentroid ( const TriangleMeshType Mesh)
inlinestatic

Get the average of the mesh vertices.

◆ GetTrianglesBounds()

template<class TriangleMeshType >
static FAxisAlignedBox3d UE::Geometry::TMeshQueries< TriangleMeshType >::GetTrianglesBounds ( const TriangleMeshType Mesh,
const EnumerableTriListType Triangles,
const FTransform Transform = FTransform::Identity 
)
inlinestatic
Returns
bounding box of subset of triangles of Mesh

◆ GetTriBounds()

template<class TriangleMeshType >
static FAxisAlignedBox3d UE::Geometry::TMeshQueries< TriangleMeshType >::GetTriBounds ( const TriangleMeshType Mesh,
int  TID 
)
inlinestatic

◆ GetTriCentroid()

template<class TriangleMeshType >
static FVector3d UE::Geometry::TMeshQueries< TriangleMeshType >::GetTriCentroid ( const TriangleMeshType Mesh,
int  TriIdx 
)
inlinestatic

Compute triangle centroid

Parameters
MeshMesh with triangle
TriIdxIndex of triangle
Returns
Computed centroid

◆ GetTriNormalAreaCentroid()

template<class TriangleMeshType >
static void UE::Geometry::TMeshQueries< TriangleMeshType >::GetTriNormalAreaCentroid ( const TriangleMeshType Mesh,
int  TriIdx,
FVector3d Normal,
double Area,
FVector3d Centroid 
)
inlinestatic

Compute the normal, area, and centroid of a triangle all together

Parameters
MeshMesh w/ triangle
TriIdxIndex of triangle
NormalComputed normal (returned by reference)
AreaComputed area (returned by reference)
CentroidComputed centroid (returned by reference)

◆ GetVertexSelectedTriangles()

template<class TriangleMeshType >
static TArray< int32 > UE::Geometry::TMeshQueries< TriangleMeshType >::GetVertexSelectedTriangles ( const TriangleMeshType Mesh,
const TArray< int32 > &  Vertices 
)
inlinestatic

Get triangles that contain at least on vertex in the Vertices array.

Parameters
VerticesArray of mesh vertex IDs.
TrianglesTriangle IDs containing at least one vertex ID in Vertices.

◆ GetVertexWeightsOnTriangle()

template<class TriangleMeshType >
static FVector3d UE::Geometry::TMeshQueries< TriangleMeshType >::GetVertexWeightsOnTriangle ( const TriangleMeshType Mesh,
int  TriID,
double  TriArea,
bool  bWeightByArea,
bool  bWeightByAngle 
)
inlinestatic

Retrieve the area and/or angle weights for each vertex of a triangle.

Parameters
Meshthe mesh to query
TriIDthe triangle index of the mesh to query
TriAreathe area of the triangle
bWeightByAreaif true, include weighting by the area of the triangle
bWeightByAngleif true, include weighting by the interior angles of the triangle

◆ GetVerticesBounds()

template<class TriangleMeshType >
static FAxisAlignedBox3d UE::Geometry::TMeshQueries< TriangleMeshType >::GetVerticesBounds ( const TriangleMeshType Mesh,
const EnumerableTriListType Vertices,
const FTransform Transform = FTransform::Identity 
)
inlinestatic
Returns
bounding box of subset of vertices of Mesh

◆ GetVolumeArea() [1/2]

template<class TriangleMeshType >
static FVector2d UE::Geometry::TMeshQueries< TriangleMeshType >::GetVolumeArea ( const TriangleMeshType Mesh)
inlinestatic

◆ GetVolumeArea() [2/2]

template<class TriangleMeshType >
static FVector2d UE::Geometry::TMeshQueries< TriangleMeshType >::GetVolumeArea ( const TriangleMeshType Mesh,
const TArray< int > &  TriIndices 
)
inlinestatic

◆ GetVolumeAreaCenter()

template<class TriangleMeshType >
static FVector2d UE::Geometry::TMeshQueries< TriangleMeshType >::GetVolumeAreaCenter ( const TriangleMeshType Mesh,
FVector3d OutCenterOfMass 
)
inlinestatic

◆ GetVolumeNonWatertight()

template<class TriangleMeshType >
static double UE::Geometry::TMeshQueries< TriangleMeshType >::GetVolumeNonWatertight ( const TriangleMeshType Mesh,
double  DimScaleFactor = 1 
)
inlinestatic

Get the volume of a mesh using a method that is more robust to inputs with holes

Parameters
MeshInput shape
DimScaleFactorScale factor to apply to each dimension; useful for keeping volume calculation in a good range for floating point precision
Returns
Mesh volume (scaled by DimScaleFactor^3)

◆ HausdorffDistance()

template<class TriangleMeshType >
static double UE::Geometry::TMeshQueries< TriangleMeshType >::HausdorffDistance ( const TriangleMeshType MeshA,
const MeshSpatialType SpatialB 
)
inlinestatic

Compute all vertex-to-surface distances in parallel. Serial raw loop to find max element (using Algo::MaxElement was never faster in initial benchmarking.)

Parameters
MeshAThe mesh whose maximum vertex distance should be computed.
SpatialBThe target surface's acceleration structure.
Returns
The maximum distance to the surface contained in SpatialB over all vertices in MeshA.

◆ HausdorffDistanceSerial()

template<class TriangleMeshType >
static double UE::Geometry::TMeshQueries< TriangleMeshType >::HausdorffDistanceSerial ( const TriangleMeshType MeshA,
const MeshSpatialType SpatialB 
)
inlinestatic

Compute all distances in serial, then a serial raw loop to find max. Should only be used for debugging the parallel version above!

◆ MaxEdgeLength()

template<class TriangleMeshType >
static double UE::Geometry::TMeshQueries< TriangleMeshType >::MaxEdgeLength ( const TriangleMeshType Mesh)
inlinestatic

Compute the longest edge length for the given mesh.

◆ MeshDistanceStatistics()

template<class TriangleMeshType >
static void UE::Geometry::TMeshQueries< TriangleMeshType >::MeshDistanceStatistics ( const TriangleMeshType MeshA,
const MeshSpatialType SpatialB,
const TriangleMeshType MeshB,
const MeshSpatialType SpatialA,
bool  bSymmetric,
double MaxDistance,
double MinDistance,
double AverageDistance,
double RootMeanSqrDeviation 
)
inlinestatic

Compute various statistics on distances between two meshes

◆ MinEdgeLength()

template<class TriangleMeshType >
static double UE::Geometry::TMeshQueries< TriangleMeshType >::MinEdgeLength ( const TriangleMeshType Mesh)
inlinestatic

Compute the shortest edge length for the given mesh.

◆ RayTriangleIntersection()

template<class TriangleMeshType >
template<typename RayType = FRay3d>
static FIntrRay3Triangle3d UE::Geometry::TMeshQueries< TriangleMeshType >::RayTriangleIntersection ( const TriangleMeshType Mesh,
int  TriIdx,
const RayType Ray 
)
inlinestatic

convenience function to construct a IntrRay3Triangle3 object for a Mesh triangle

◆ TotalEdgeLength()

template<class TriangleMeshType >
static double UE::Geometry::TMeshQueries< TriangleMeshType >::TotalEdgeLength ( const TriangleMeshType Mesh,
const TArray< int > &  Edges 
)
inlinestatic

Given a mesh and a subset of mesh edges, compute the total length of all the edges.

◆ TriangleDistance()

template<class TriangleMeshType >
static FDistPoint3Triangle3d UE::Geometry::TMeshQueries< TriangleMeshType >::TriangleDistance ( const TriangleMeshType Mesh,
int  TriIdx,
FVector3d  Point 
)
inlinestatic

construct a DistPoint3Triangle3 object for a Mesh triangle

◆ TriangleIntersection()

template<class TriangleMeshType >
static FIntrRay3Triangle3d UE::Geometry::TMeshQueries< TriangleMeshType >::TriangleIntersection ( const TriangleMeshType Mesh,
int  TriIdx,
const FRay3d Ray 
)
inlinestatic

convenience function to construct a IntrRay3Triangle3 object for a Mesh triangle

◆ TriDistanceSqr()

template<class TriangleMeshType >
static double UE::Geometry::TMeshQueries< TriangleMeshType >::TriDistanceSqr ( const TriangleMeshType Mesh,
int  TriIdx,
const FVector3d Point 
)
inlinestatic

Compute distance from Point to triangle in Mesh, with minimal extra objects/etc

◆ TwoSidedHausdorffDistance()

template<class TriangleMeshType >
static double UE::Geometry::TMeshQueries< TriangleMeshType >::TwoSidedHausdorffDistance ( const TriangleMeshType MeshA,
const MeshSpatialType SpatialA,
const TriangleMeshType MeshB,
const MeshSpatialType SpatialB 
)
inlinestatic

Because Hausdorff distance is not symmetric, we compute the maximum of the distances between two surfaces.

◆ TwoSidedHausdorffDistanceSerial()

template<class TriangleMeshType >
static double UE::Geometry::TMeshQueries< TriangleMeshType >::TwoSidedHausdorffDistanceSerial ( const TriangleMeshType MeshA,
const MeshSpatialType SpatialA,
const TriangleMeshType MeshB,
const MeshSpatialType SpatialB 
)
inlinestatic

◆ VertexToSurfaceDistances()

template<class TriangleMeshType >
static void UE::Geometry::TMeshQueries< TriangleMeshType >::VertexToSurfaceDistances ( const TriangleMeshType MeshA,
const MeshSpatialType SpatialB,
TArray< double > &  Distances 
)
inlinestatic

For each vertex on MeshA, compute the distance to the nearest point on the surface contained in SpatialB.

Parameters
MeshAThe mesh whose vertex distances should be computed.
SpatialBThe target surface's acceleration structure.
DistancesFor each vertex in MeshA, the distance to the closest point in SpatialB.

◆ VertexToSurfaceDistancesSerial()

template<class TriangleMeshType >
static void UE::Geometry::TMeshQueries< TriangleMeshType >::VertexToSurfaceDistancesSerial ( const TriangleMeshType MeshA,
const MeshSpatialType SpatialB,
TArray< double > &  Distances 
)
inlinestatic

Compute all vertex-to-surface distances in serial. Should only be used for debugging the parallel version above!


The documentation for this class was generated from the following file: