UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
EmbedSurfacePath.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3// Port of geometry3Sharp MeshPlaneCut
4
5#pragma once
6#include "CoreMinimal.h"
7
8#include "MathUtil.h"
9#include "VectorTypes.h"
10#include "FrameTypes.h"
11#include "GeometryTypes.h"
14
15
16namespace UE
17{
18namespace Geometry
19{
20
21class FDynamicMesh3;
22
24{
25 Vertex = 0,
26 Edge = 1,
27 Triangle = 2
28};
29
51
55//bool GEOMETRYCORE_API WalkMeshPlanar(
56// const FDynamicMesh3* Mesh, int StartTri, int EndVertID, FVector3d StartPt, int EndTri, FVector3d EndPt, FVector3d WalkPlaneNormal,
57// TFunction<FVector3d(const FDynamicMesh3*, int)> VertexToPosnFn, bool bAllowBackwardsSearch, double AcceptEndPtOutsideDist,
58// double PtOnPlaneThreshold, TArray<TPair<FMeshSurfacePoint, int>>& WalkedPath, double BackwardsTolerance = FMathd::ZeroTolerance * 10);
59
60
65{
66public:
68 TArray<TPair<FMeshSurfacePoint, int>> Path; // Surface points paired with triangle to walk to get to next surface point
70
71public:
72
79 virtual ~FMeshSurfacePath() {}
80
81 // TODO: not clear if we need this -- helper to find the shared triangle (if it exists) that we could traverse to connect two surface points. this gets a bit hairy and it's easier to keep track of the traversed triangles during the mesh walk that creates any path in the first place
82 //static int FindSharedTriangle(const FDynamicMesh3* Mesh, const FMeshSurfacePoint& A, const FMeshSurfacePoint& B);
83
87 GEOMETRYCORE_API bool IsConnected() const;
88
89 bool IsClosed() const
90 {
91 return bIsClosed;
92 }
93
94 void Reset()
95 {
96 Path.Reset();
97 bIsClosed = false;
98 }
99
102 bool bAllowBackwardsSearch = true, double AcceptEndPtOutsideDist = FMathd::ZeroTolerance,
103 double PtOnPlaneThresholdSq = FMathf::ZeroTolerance*100, double BackwardsTolerance = FMathd::ZeroTolerance*10);
104 // TODO: Also support geodesic walks, other alternatives?
105
112
125
126 // TODO: support for embedding arbitrary paths in mesh using a graph remesher
128 // * Embed surface path in mesh, such that each point in path is a mesh vertex with a connecting edge. Note that IsConnected must be true for this to succeed.
129 // *
130 // * @param bUpdatePath Updating the Path array with the new vertices (if false, the path will no longer be valid after running this function)
131 // * @param PathVertices Indices of the vertices on the path after embedding succeeds; NOTE these will not be 1:1 with the input Path
132 // * @param MeshGraphFn Function to create a mesh from an input 2D graph of labeled edges.
133 // * @return true if embedding succeeded.
134 // */
135 //bool EmbedPath(bool bUpdatePath, TArray<int>& PathVertices, TFunction<bool(const TArray<FVector2d>& Vertices, const TArray<FIndex3i>& LabelledEdges, TArray<FVector2d>& OutVertices, TArray<int32>& OutVertexMap, TArray<FIndex3i>& OutTriangles)> MeshGraphFn);
136
144 GEOMETRYCORE_API bool EmbedSimplePath(bool bUpdatePath, TArray<int>& PathVertices, bool bDoNotDuplicateFirstVertexID = true, double SnapElementThresholdSq = FMathf::ZeroTolerance*100);
145
146 // TODO: add functionality to delete 'inside' of path -- but how do we determine what is inside? ref MeshFacesFromLoop.cs in geometry3sharp
147};
148
152bool GEOMETRYCORE_API EmbedProjectedPath(FDynamicMesh3* Mesh, int StartTriID, FFrame3d Frame, const TArray<FVector2d>& Path2D, TArray<int>& OutPathVertices, TArray<int>& OutVertexCorrespondence, bool bClosePath, FMeshFaceSelection *EnclosedFaces = nullptr, double PtSnapVertexOrEdgeThresholdSq = FMathf::ZeroTolerance*100);
153
158
159
160} // end namespace UE::Geometry
161} // end namespace UE
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::Math::TVector< double > FVector3d
Definition MathFwd.h:60
Definition ArrayView.h:139
Definition Array.h:670
Definition AndroidPlatformMisc.h:14
Definition DynamicMesh3.h:108
Definition EmbedSurfacePath.h:65
GEOMETRYCORE_API bool AddViaPlanarWalk(int StartTri, int StartVID, FVector3d StartPt, int EndTri, int EndVertID, FVector3d EndPt, FVector3d WalkPlaneNormal, TFunction< FVector3d(const FDynamicMesh3 *, int)> VertexToPosnFn=nullptr, bool bAllowBackwardsSearch=true, double AcceptEndPtOutsideDist=FMathd::ZeroTolerance, double PtOnPlaneThresholdSq=FMathf::ZeroTolerance *100, double BackwardsTolerance=FMathd::ZeroTolerance *10)
Definition EmbedSurfacePath.cpp:613
GEOMETRYCORE_API bool ClosePath()
virtual EOperationValidationResult Validate()
Definition EmbedSurfacePath.h:116
bool bIsClosed
Definition EmbedSurfacePath.h:69
FMeshSurfacePath(FDynamicMesh3 *Mesh)
Definition EmbedSurfacePath.h:76
FDynamicMesh3 * Mesh
Definition EmbedSurfacePath.h:67
virtual ~FMeshSurfacePath()
Definition EmbedSurfacePath.h:79
GEOMETRYCORE_API bool IsConnected() const
Definition EmbedSurfacePath.cpp:567
void Reset()
Definition EmbedSurfacePath.h:94
TArray< TPair< FMeshSurfacePoint, int > > Path
Definition EmbedSurfacePath.h:68
GEOMETRYCORE_API bool EmbedSimplePath(bool bUpdatePath, TArray< int > &PathVertices, bool bDoNotDuplicateFirstVertexID=true, double SnapElementThresholdSq=FMathf::ZeroTolerance *100)
‍**
Definition EmbedSurfacePath.cpp:663
bool IsClosed() const
Definition EmbedSurfacePath.h:89
bool GEOMETRYCORE_API EmbedProjectedPaths(FDynamicMesh3 *Mesh, const TArrayView< const int > StartTriIDs, FFrame3d Frame, const TArrayView< const TArray< FVector2d > > AllPaths, TArray< TArray< int > > &OutAllPathVertices, TArray< TArray< int > > &OutAllVertexCorrespondence, bool bClosePaths, FMeshFaceSelection *EnclosedFaces, double PtSnapVertexOrEdgeThresholdSq=FMathf::ZeroTolerance *100)
Definition EmbedSurfacePath.cpp:831
ESurfacePointType
Definition EmbedSurfacePath.h:24
EOperationValidationResult
Definition GeometryTypes.h:59
bool GEOMETRYCORE_API EmbedProjectedPath(FDynamicMesh3 *Mesh, int StartTriID, FFrame3d Frame, const TArray< FVector2d > &Path2D, TArray< int > &OutPathVertices, TArray< int > &OutVertexCorrespondence, bool bClosePath, FMeshFaceSelection *EnclosedFaces=nullptr, double PtSnapVertexOrEdgeThresholdSq=FMathf::ZeroTolerance *100)
Definition EmbedSurfacePath.cpp:995
TFrame3< double > FFrame3d
Definition FrameTypes.h:478
Definition AdvancedWidgetsModule.cpp:13
@ false
Definition radaudio_common.h:23
Definition EmbedSurfacePath.h:31
FVector3d BaryCoord
Definition EmbedSurfacePath.h:33
FMeshSurfacePoint(int TriangleID, const FVector3d &BaryCoord)
Definition EmbedSurfacePath.h:39
ESurfacePointType PointType
Definition EmbedSurfacePath.h:34
FMeshSurfacePoint()
Definition EmbedSurfacePath.h:36
FMeshSurfacePoint(int VertexID)
Definition EmbedSurfacePath.h:45
GEOMETRYCORE_API FVector3d Pos(const FDynamicMesh3 *Mesh) const
Definition EmbedSurfacePath.cpp:13
int ElementID
Definition EmbedSurfacePath.h:32
FMeshSurfacePoint(int EdgeID, double FirstCoordWt)
Definition EmbedSurfacePath.h:42