Files
UnrealEngine/Engine/Plugins/Experimental/GeometryFlow/Source/GeometryFlowMeshProcessing/Private/MeshProcessingNodes/GenerateConvexHullMeshNode.cpp
2025-05-18 13:04:45 +08:00

38 lines
1011 B
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "MeshProcessingNodes/GenerateConvexHullMeshNode.h"
#include "Operations/MeshConvexHull.h"
using namespace UE::Geometry;
using namespace UE::GeometryFlow;
EGeometryFlowResult FGenerateConvexHullMeshNode::MakeConvexHullMesh(const FDynamicMesh3& MeshIn,
const FGenerateConvexHullMeshSettings& Settings,
FDynamicMesh3& MeshOut,
TUniquePtr<FEvaluationInfo>& EvaluationInfo)
{
FMeshConvexHull Hull(&MeshIn);
if (Settings.bPrefilterVertices)
{
FMeshConvexHull::GridSample(MeshIn, Settings.PrefilterGridResolution, Hull.VertexSet);
}
Hull.bPostSimplify = false; // Mesh can be simplified later
if (Hull.Compute(EvaluationInfo->Progress))
{
MeshOut = MoveTemp(Hull.ConvexHull);
}
if (EvaluationInfo->Progress->Cancelled())
{
return EGeometryFlowResult::OperationCancelled;
}
// TODO: What if Hull.Compute() fails but not because of cancellation? Should we have a EGeometryFlowResult::Failed?
return EGeometryFlowResult::Ok;
}