UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE::Geometry::FMeshBoolean Class Reference

#include <MeshBoolean.h>

Classes

struct  FCustomInsideMeshTest
 
struct  FCustomInsideTestContext
 

Public Types

enum class  EBooleanOp {
  Union , Difference , Intersect , TrimInside ,
  TrimOutside , NewGroupInside , NewGroupOutside
}
 
using TestInsideFunctionType = TFunction< bool(const FVector3d &TestPosition, const FCustomInsideTestContext &Context)>
 

Public Member Functions

 FMeshBoolean (const FDynamicMesh3 *MeshA, const FTransformSRT3d &TransformA, const FDynamicMesh3 *MeshB, const FTransformSRT3d &TransformB, FDynamicMesh3 *OutputMesh, EBooleanOp Operation)
 
 FMeshBoolean (const FDynamicMesh3 *MeshA, const FDynamicMesh3 *MeshB, FDynamicMesh3 *OutputMesh, EBooleanOp Operation)
 
virtual ~FMeshBoolean ()
 
EOperationValidationResult Validate ()
 
GEOMETRYCORE_API bool Compute ()
 
GEOMETRYCORE_API bool ComputeWithCustomInside (FCustomInsideMeshTest TestMeshA, FCustomInsideMeshTest TestMeshB)
 

Public Attributes

const FDynamicMesh3Meshes [2]
 
const FTransformSRT3d Transforms [2]
 
EBooleanOp Operation
 
double SnapTolerance = FMathf::ZeroTolerance * 1.0
 
bool bCollapseDegenerateEdgesOnCut = true
 
double DegenerateEdgeTolFactor = 1.5
 
double WindingThreshold = .5
 
bool bPutResultInInputSpace = true
 
bool bWeldSharedEdges = true
 
bool bTrackAllNewEdges = false
 
FProgressCancelProgress = nullptr
 
bool bSimplifyAlongNewEdges = false
 
double SimplificationAngleTolerance = .1
 
double TryToImproveTriQualityThreshold = .5
 
bool bPreserveTriangleGroups = true
 
bool bPreserveVertexUVs = true
 
bool bPreserveOverlayUVs = true
 
float UVDistortTolerance = FMathf::ZeroTolerance
 
bool bPreserveVertexNormals = true
 
float NormalDistortTolerance = .01f
 
int PreserveUVsOnlyForMesh = -1
 
FDynamicMesh3Result
 
FTransformSRT3d ResultTransform
 
TArray< int > CreatedBoundaryEdges
 
TSet< int32AllNewEdges
 
bool bPopulateSecondMeshGroupMap = false
 
FIndexMapi SecondMeshGroupMap
 
TOptional< TArray< int8 > > TrackPerTriangleSourceMesh
 

Protected Member Functions

virtual bool Cancelled ()
 

Detailed Description

MeshBoolean – perform a boolean operation on two input meshes.

Member Typedef Documentation

◆ TestInsideFunctionType

Member Enumeration Documentation

◆ EBooleanOp

Enumerator
Union 
Difference 
Intersect 
TrimInside 
TrimOutside 
NewGroupInside 
NewGroupOutside 

Constructor & Destructor Documentation

◆ FMeshBoolean() [1/2]

UE::Geometry::FMeshBoolean::FMeshBoolean ( const FDynamicMesh3 MeshA,
const FTransformSRT3d TransformA,
const FDynamicMesh3 MeshB,
const FTransformSRT3d TransformB,
FDynamicMesh3 OutputMesh,
EBooleanOp  Operation 
)
inline

Perform a boolean operation to combine two meshes into a provided output mesh.

Parameters
MeshAFirst mesh to combine
TransformATransform of MeshA
MeshBSecond mesh to combine
TransformBTransform of MeshB
OutputMeshMesh to store output
OperationHow to combine meshes

◆ FMeshBoolean() [2/2]

UE::Geometry::FMeshBoolean::FMeshBoolean ( const FDynamicMesh3 MeshA,
const FDynamicMesh3 MeshB,
FDynamicMesh3 OutputMesh,
EBooleanOp  Operation 
)
inline

◆ ~FMeshBoolean()

virtual UE::Geometry::FMeshBoolean::~FMeshBoolean ( )
inlinevirtual

Member Function Documentation

◆ Cancelled()

virtual bool UE::Geometry::FMeshBoolean::Cancelled ( )
inlineprotectedvirtual

If this returns true, abort computation.

◆ Compute()

bool FMeshBoolean::Compute ( )

Compute the Boolean operation, using winding number for inside/outside tests

Returns
true if operation succeeds

◆ ComputeWithCustomInside()

bool FMeshBoolean::ComputeWithCustomInside ( FCustomInsideMeshTest  TestMeshA,
FCustomInsideMeshTest  TestMeshB 
)

Compute the Boolean operation with a custom function determining if points are inside the given mesh

◆ Validate()

EOperationValidationResult UE::Geometry::FMeshBoolean::Validate ( )
inline
Returns
EOperationValidationResult::Ok if we can apply operation, or error code if we cannot

Member Data Documentation

◆ AllNewEdges

TSet<int32> UE::Geometry::FMeshBoolean::AllNewEdges

All edges created by mesh boolean algorithm. Only populated if bTrackAllNewEdges = true

◆ bCollapseDegenerateEdgesOnCut

bool UE::Geometry::FMeshBoolean::bCollapseDegenerateEdgesOnCut = true

Whether to do additional processing to try to remove degenerate edges

◆ bPopulateSecondMeshGroupMap

bool UE::Geometry::FMeshBoolean::bPopulateSecondMeshGroupMap = false

When doing an operation that merges two meshes (Union, Difference, Intersect) and bPopulateSecondMeshGroupMap is true, we populate a map from group ID's in the second mesh to group ID's in the result. Useful when the boolean is part of another operation that might want to track selection into the result.

TODO: It would be nice to have a similar triangle map, but it's more tedious to implement due to the mesh cuts that happen. We might also someday want something similar for the first mesh, where the group ID's will usually stay the same except when all triangles of a particular group are removed and the group ID is repurposed for the second mesh...

◆ bPreserveOverlayUVs

bool UE::Geometry::FMeshBoolean::bPreserveOverlayUVs = true

Prevent simplification from distorting overlay UVs

◆ bPreserveTriangleGroups

bool UE::Geometry::FMeshBoolean::bPreserveTriangleGroups = true

Prevent simplification from distorting triangle groups

◆ bPreserveVertexNormals

bool UE::Geometry::FMeshBoolean::bPreserveVertexNormals = true

Prevent simplification from distorting vertex normals

◆ bPreserveVertexUVs

bool UE::Geometry::FMeshBoolean::bPreserveVertexUVs = true

Prevent simplification from distorting vertex UVs

◆ bPutResultInInputSpace

bool UE::Geometry::FMeshBoolean::bPutResultInInputSpace = true

Put the Result mesh in the same space as the input. If true, ResultTransform will be the identity transform.

◆ bSimplifyAlongNewEdges

bool UE::Geometry::FMeshBoolean::bSimplifyAlongNewEdges = false

Control whether we attempt to auto-simplify the small planar triangles that the boolean operation tends to generate

◆ bTrackAllNewEdges

bool UE::Geometry::FMeshBoolean::bTrackAllNewEdges = false

Control whether new edges should be tracked

◆ bWeldSharedEdges

bool UE::Geometry::FMeshBoolean::bWeldSharedEdges = true

Weld newly-created cut edges where the input meshes meet. If false, the input meshes will remain topologically disconnected.

◆ CreatedBoundaryEdges

TArray<int> UE::Geometry::FMeshBoolean::CreatedBoundaryEdges

Boundary edges created by the mesh boolean algorithm failing to cleanly weld (doesn't include boundaries that already existed in source meshes)

◆ DegenerateEdgeTolFactor

double UE::Geometry::FMeshBoolean::DegenerateEdgeTolFactor = 1.5

Tolerance factor (multiplied by SnapTolerance) for removing short edges created by the cutting process; should be no more than 2

◆ Meshes

const FDynamicMesh3* UE::Geometry::FMeshBoolean::Meshes[2]

◆ NormalDistortTolerance

float UE::Geometry::FMeshBoolean::NormalDistortTolerance = .01f

When preserving normals, sets maximum allowed change in normals from collapsing an edge, measured at the removed vertex in degrees

◆ Operation

EBooleanOp UE::Geometry::FMeshBoolean::Operation

◆ PreserveUVsOnlyForMesh

int UE::Geometry::FMeshBoolean::PreserveUVsOnlyForMesh = -1

If > -1, then only preserve the UVs of one of the input meshes. Useful when cutting an artist-created asset w/ procedural geometry.

◆ Progress

FProgressCancel* UE::Geometry::FMeshBoolean::Progress = nullptr

Set this to be able to cancel running operation

◆ Result

FDynamicMesh3* UE::Geometry::FMeshBoolean::Result

◆ ResultTransform

FTransformSRT3d UE::Geometry::FMeshBoolean::ResultTransform

Transform taking the result mesh back to the original space of the inputs

◆ SecondMeshGroupMap

FIndexMapi UE::Geometry::FMeshBoolean::SecondMeshGroupMap

◆ SimplificationAngleTolerance

double UE::Geometry::FMeshBoolean::SimplificationAngleTolerance = .1

Degrees of deviation from coplanar that we will still simplify

◆ SnapTolerance

double UE::Geometry::FMeshBoolean::SnapTolerance = FMathf::ZeroTolerance * 1.0

Tolerance distance for considering a point to be on a vertex or edge, especially during mesh-mesh cutting

◆ TrackPerTriangleSourceMesh

TOptional<TArray<int8> > UE::Geometry::FMeshBoolean::TrackPerTriangleSourceMesh

◆ Transforms

const FTransformSRT3d UE::Geometry::FMeshBoolean::Transforms[2]

◆ TryToImproveTriQualityThreshold

double UE::Geometry::FMeshBoolean::TryToImproveTriQualityThreshold = .5

If triangle quality (aspect ratio) is worse than this threshold, only simplify in ways that improve quality. If <= 0, triangle quality is ignored. Note: For aspect ratio we use definition: 4*TriArea / (sqrt(3)*MaxEdgeLen^2), ref: https://people.eecs.berkeley.edu/~jrs/papers/elemj.pdf p.53 Equilateral triangles have value 1; Smaller values -> lower quality

◆ UVDistortTolerance

float UE::Geometry::FMeshBoolean::UVDistortTolerance = FMathf::ZeroTolerance

When preserving UVs, sets maximum allowed change in UV coordinates from collapsing an edge, measured at the removed vertex

◆ WindingThreshold

double UE::Geometry::FMeshBoolean::WindingThreshold = .5

Threshold to determine whether triangle in one mesh is inside or outside of the other


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