Files
UnrealEngineUWP/Engine/Plugins/Runtime/MeshModelingToolset/Source/MeshModelingTools/Public/CutMeshWithMeshTool.h
lonnie li 6584198283 InteractiveToolsFramework: Remove unnecessary target interface functions from MultiSelectionTool.
ModelingTools: Add UMultiSelectionMeshEditingTool to hold common interface requirements and functions that pertain to modeling mode MultiSelectionTools.

#rb semion.piskarev
#rnx
#jira none
#preflight 619c66d5c3287aab27e12c73

#ROBOMERGE-AUTHOR: lonnie.li
#ROBOMERGE-SOURCE: CL 18269697 in //UE5/Release-5.0/... via CL 18269713
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469)

[CL 18269717 by lonnie li in ue5-release-engine-test branch]
2021-11-23 09:42:40 -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 Shutdown(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);
}
};