Files
UnrealEngineUWP/Engine/Plugins/Runtime/MeshModelingToolset/Source/MeshModelingTools/Public/CutMeshWithMeshTool.h
lonnie li 4afd669dcb ModelingTools: Clear TargetWorld member during Shutdown of SingleSelectionMeshEditingTool and MultiSelectionMeshEditingTool
#rb ryan.schmidt michael.balzer
#rnx
#jira none
#preflight 61f435dd74510448a6865d14

#ROBOMERGE-AUTHOR: lonnie.li
#ROBOMERGE-SOURCE: CL 18777332 in //UE5/Release-5.0/... via CL 18780413 via CL 18780555
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v903-18687472)

[CL 18780558 by lonnie li in ue5-main branch]
2022-01-28 18:40:54 -05:00

128 lines
3.6 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "Drawing/LineSetComponent.h"
#include "BaseTools/BaseCreateFromSelectedTool.h"
#include "CutMeshWithMeshTool.generated.h"
// Forward declarations
class UPreviewMesh;
PREDECLARE_USE_GEOMETRY_CLASS(FDynamicMesh3);
/**
* Standard properties of the CutMeshWithMesh operation
*/
UCLASS()
class MESHMODELINGTOOLS_API UCutMeshWithMeshToolProperties : public UInteractiveToolPropertySet
{
GENERATED_BODY()
public:
/** Try to fill holes created by the Boolean operation, e.g. due to numerical errors */
UPROPERTY(EditAnywhere, Category = Boolean, AdvancedDisplay)
bool bTryFixHoles = false;
/** Try to collapse extra edges created by the Boolean operation */
UPROPERTY(EditAnywhere, Category = Boolean, AdvancedDisplay)
bool bTryCollapseEdges = true;
/** Threshold to determine whether a triangle in one mesh is inside or outside of the other */
UPROPERTY(EditAnywhere, Category = Boolean, AdvancedDisplay, meta = (UIMin = "0", UIMax = "1"))
float WindingThreshold = 0.5;
/** Show boundary edges created by the Boolean operation, which might happen due to numerical errors */
UPROPERTY(EditAnywhere, Category = Display)
bool bShowNewBoundaries = true;
/** If true, only the first mesh will keep its material assignments, and all other faces will have the first material assigned */
UPROPERTY(EditAnywhere, Category = Materials)
bool bUseFirstMeshMaterials = false;
};
/**
* UCutMeshWithMeshTool cuts an input mesh into two pieces based on a second input mesh.
* Essentially this just both a Boolean Subtract and a Boolean Intersection. However
* doing those as two separate operations involves quite a few steps, so this Tool
* does it in a single step and with some improved efficiency.
*/
UCLASS()
class MESHMODELINGTOOLS_API UCutMeshWithMeshTool : public UBaseCreateFromSelectedTool
{
GENERATED_BODY()
public:
UCutMeshWithMeshTool() {}
protected:
virtual void OnPropertyModified(UObject* PropertySet, FProperty* Property) override;
virtual void ConvertInputsAndSetPreviewMaterials(bool bSetPreviewMesh = true) override;
virtual void SetupProperties() override;
virtual void SaveProperties() override;
virtual void SetPreviewCallbacks() override;
virtual FString GetCreatedAssetName() const override;
virtual FText GetActionName() const override;
// IDynamicMeshOperatorFactory API
virtual TUniquePtr<UE::Geometry::FDynamicMeshOperator> MakeNewOperator() override;
virtual void OnShutdown(EToolShutdownType ShutdownType) override;
void UpdateVisualization();
UPROPERTY()
TObjectPtr<UCutMeshWithMeshToolProperties> CutProperties;
UPROPERTY()
TObjectPtr<UPreviewMesh> IntersectPreviewMesh;
TSharedPtr<FDynamicMesh3, ESPMode::ThreadSafe> OriginalTargetMesh;
TSharedPtr<FDynamicMesh3, ESPMode::ThreadSafe> OriginalCuttingMesh;
UPROPERTY()
TObjectPtr<ULineSetComponent> DrawnLineSet;
// for visualization of any errors in the currently-previewed CSG operation
TArray<int> CreatedSubtractBoundaryEdges;
TArray<int> CreatedIntersectBoundaryEdges;
FDynamicMesh3 IntersectionMesh;
};
UCLASS()
class MESHMODELINGTOOLS_API UCutMeshWithMeshToolBuilder : public UBaseCreateFromSelectedToolBuilder
{
GENERATED_BODY()
public:
virtual TOptional<int32> MaxComponentsSupported() const override
{
return TOptional<int32>(2);
}
virtual int32 MinComponentsSupported() const override
{
return 2;
}
virtual UMultiSelectionMeshEditingTool* CreateNewTool(const FToolBuilderState& SceneState) const override
{
return NewObject<UCutMeshWithMeshTool>(SceneState.ToolManager);
}
};