UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
MeshBoolean.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3// Port of geometry3Sharp MeshBoolean
4
5#pragma once
6
7#include "MathUtil.h"
8#include "VectorTypes.h"
9#include "GeometryTypes.h"
10
11#include "DynamicMeshEditor.h"
12
13#include "Spatial/FastWinding.h"
15
16#include "Util/ProgressCancel.h"
17
18
19namespace UE
20{
21namespace Geometry
22{
23
24
25
30{
31public:
32
33 //
34 // Inputs
35 //
38
39 enum class EBooleanOp
40 {
41 Union,
48 };
50
51
52
54 double SnapTolerance = FMathf::ZeroTolerance * 1.0;
55
60
62 double WindingThreshold = .5;
63
66
68 bool bWeldSharedEdges = true;
69
71 bool bTrackAllNewEdges = false;
72
75
78 //
79 // Simplification-specific settings (only relevant if bSimplifyAlongNewEdges==true):
80 //
92 bool bPreserveVertexUVs = true;
96 float UVDistortTolerance = FMathf::ZeroTolerance;
103
104
105
106 //
107 // Input & Output (to be modified by algorithm)
108 //
109
110 // An existing mesh, to be filled with the boolean result
112
113 //
114 // Output
115 //
116
119
122
125
140
141 // If set, will be populated with an array of source mesh indices per TriangleID in the result mesh,
142 // indicating if that triangle was from the Meshes[0] or Meshes[1] source.
143 // Note: For non-compact meshes, invalid triangle IDs will have arbitrary indices.
145
146public:
147
163
166 {
167 check(MeshA != nullptr && MeshB != nullptr && OutputMesh != nullptr);
168 }
169
171 {}
172
177 {
178 // @todo validate inputs
180 }
181
187
188 // Data passed to the FCustomInsideMeshTest::IsPointInsideFn
190 {
191 // AABB Tree for the test mesh; always non-null
193 // Note: OptionalWindingTree will be null when FCustomInsideMeshTest has bRequiresWinding == false
195 };
196
197 // Function type for custom inside/outside query functions
198 // Note: If implementing a custom function that needs to access the underlying mesh, it is accessible via Context.Spatial->GetMesh()
216
220 GEOMETRYCORE_API bool ComputeWithCustomInside(FCustomInsideMeshTest TestMeshA, FCustomInsideMeshTest TestMeshB);
221
222protected:
224 virtual bool Cancelled()
225 {
226 return (Progress == nullptr) ? false : Progress->Cancelled();
227 }
228
229private:
230
231 GEOMETRYCORE_API int FindNearestEdge(const FDynamicMesh3& OnMesh, const TArray<int>& EIDs, FVector3d Pos);
232
234
236
237};
238
239
240} // end namespace UE::Geometry
241} // end namespace UE
#define check(expr)
Definition AssertionMacros.h:314
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
const bool
Definition NetworkReplayStreaming.h:178
Definition ProgressCancel.h:187
bool Cancelled()
Definition ProgressCancel.h:243
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition DynamicMesh3.h:108
Definition MeshBoolean.h:30
FProgressCancel * Progress
Definition MeshBoolean.h:74
double DegenerateEdgeTolFactor
Definition MeshBoolean.h:59
double SnapTolerance
Definition MeshBoolean.h:54
double WindingThreshold
Definition MeshBoolean.h:62
FIndexMapi SecondMeshGroupMap
Definition MeshBoolean.h:139
double TryToImproveTriQualityThreshold
Definition MeshBoolean.h:88
FTransformSRT3d ResultTransform
Definition MeshBoolean.h:118
virtual ~FMeshBoolean()
Definition MeshBoolean.h:170
TArray< int > CreatedBoundaryEdges
Definition MeshBoolean.h:121
GEOMETRYCORE_API bool Compute()
Definition MeshBoolean.cpp:208
FMeshBoolean(const FDynamicMesh3 *MeshA, const FDynamicMesh3 *MeshB, FDynamicMesh3 *OutputMesh, EBooleanOp Operation)
Definition MeshBoolean.h:164
bool bCollapseDegenerateEdgesOnCut
Definition MeshBoolean.h:57
bool bPreserveTriangleGroups
Definition MeshBoolean.h:90
const FTransformSRT3d Transforms[2]
Definition MeshBoolean.h:37
TSet< int32 > AllNewEdges
Definition MeshBoolean.h:124
int PreserveUVsOnlyForMesh
Definition MeshBoolean.h:102
bool bWeldSharedEdges
Definition MeshBoolean.h:68
double SimplificationAngleTolerance
Definition MeshBoolean.h:82
EBooleanOp
Definition MeshBoolean.h:40
bool bPreserveVertexNormals
Definition MeshBoolean.h:98
float NormalDistortTolerance
Definition MeshBoolean.h:100
EOperationValidationResult Validate()
Definition MeshBoolean.h:176
TOptional< TArray< int8 > > TrackPerTriangleSourceMesh
Definition MeshBoolean.h:144
virtual bool Cancelled()
Definition MeshBoolean.h:224
FMeshBoolean(const FDynamicMesh3 *MeshA, const FTransformSRT3d &TransformA, const FDynamicMesh3 *MeshB, const FTransformSRT3d &TransformB, FDynamicMesh3 *OutputMesh, EBooleanOp Operation)
Definition MeshBoolean.h:157
bool bPreserveOverlayUVs
Definition MeshBoolean.h:94
float UVDistortTolerance
Definition MeshBoolean.h:96
bool bTrackAllNewEdges
Definition MeshBoolean.h:71
bool bSimplifyAlongNewEdges
Definition MeshBoolean.h:77
bool bPutResultInInputSpace
Definition MeshBoolean.h:65
const FDynamicMesh3 * Meshes[2]
Definition MeshBoolean.h:36
GEOMETRYCORE_API bool ComputeWithCustomInside(FCustomInsideMeshTest TestMeshA, FCustomInsideMeshTest TestMeshB)
Definition MeshBoolean.cpp:218
bool bPopulateSecondMeshGroupMap
Definition MeshBoolean.h:138
bool bPreserveVertexUVs
Definition MeshBoolean.h:92
FDynamicMesh3 * Result
Definition MeshBoolean.h:111
EBooleanOp Operation
Definition MeshBoolean.h:49
Definition FastWinding.h:316
Definition MeshAABBTree3.h:61
EOperationValidationResult
Definition GeometryTypes.h:59
Definition AdvancedWidgetsModule.cpp:13
@ false
Definition radaudio_common.h:23
Definition Optional.h:131
TestInsideFunctionType IsPointInsideFn
Definition MeshBoolean.h:202
bool bRequiresWinding
Definition MeshBoolean.h:203
FCustomInsideMeshTest(TestInsideFunctionType IsPointInsideFn, bool bRequiresWinding=true)
Definition MeshBoolean.h:212
TFastWindingTree< FDynamicMesh3 > * OptionalWindingTree
Definition MeshBoolean.h:194
FDynamicMeshAABBTree3 * Spatial
Definition MeshBoolean.h:192
Definition MeshIndexMappings.h:22