2020-09-01 14:07:48 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
2021-06-22 02:09:15 -04:00
|
|
|
#include "BaseTools/SingleSelectionMeshEditingTool.h"
|
2021-06-13 00:36:02 -04:00
|
|
|
#include "DynamicMesh/DynamicMesh3.h"
|
2020-09-01 14:07:48 -04:00
|
|
|
#include "Physics/CollisionPropertySets.h"
|
2021-06-23 22:14:55 -04:00
|
|
|
#include "PropertySets/CreateMeshObjectTypeProperties.h"
|
2020-09-01 14:07:48 -04:00
|
|
|
#include "ExtractCollisionGeometryTool.generated.h"
|
|
|
|
|
|
|
|
|
|
class UPreviewGeometry;
|
|
|
|
|
class UPreviewMesh;
|
|
|
|
|
|
|
|
|
|
UCLASS()
|
2021-07-29 20:08:48 -04:00
|
|
|
class MESHMODELINGTOOLSEXP_API UExtractCollisionGeometryToolBuilder : public USingleSelectionMeshEditingToolBuilder
|
2020-09-01 14:07:48 -04:00
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
2021-03-24 11:11:02 -04:00
|
|
|
virtual USingleSelectionMeshEditingTool* CreateNewTool(const FToolBuilderState& SceneState) const override;
|
2020-09-01 14:07:48 -04:00
|
|
|
|
2021-03-24 11:11:02 -04:00
|
|
|
protected:
|
|
|
|
|
virtual const FToolTargetTypeRequirements& GetTargetRequirements() const override;
|
2020-09-01 14:07:48 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2021-06-22 02:09:15 -04:00
|
|
|
UENUM()
|
|
|
|
|
enum class EExtractCollisionOutputType : uint8
|
|
|
|
|
{
|
|
|
|
|
/** Simple Collision shapes (Box, Sphere, Capsule, Convex) */
|
|
|
|
|
Simple = 0,
|
|
|
|
|
/** Complex Collision Mesh */
|
|
|
|
|
Complex = 1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UCLASS()
|
2021-07-29 20:08:48 -04:00
|
|
|
class MESHMODELINGTOOLSEXP_API UExtractCollisionToolProperties : public UInteractiveToolPropertySet
|
2021-06-22 02:09:15 -04:00
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
public:
|
|
|
|
|
/** Type of collision geometry to convert to Mesh */
|
|
|
|
|
UPROPERTY(EditAnywhere, Category = Options)
|
|
|
|
|
EExtractCollisionOutputType CollisionType = EExtractCollisionOutputType::Simple;
|
|
|
|
|
|
|
|
|
|
/** Whether or not to weld coincident border edges of the Complex Collision Mesh (if possible) */
|
|
|
|
|
UPROPERTY(EditAnywhere, Category = Options, Meta = (EditCondition = "CollisionType == EExtractCollisionOutputType::Complex"))
|
|
|
|
|
bool bWeldEdges = true;
|
|
|
|
|
|
|
|
|
|
/** Whether or not to generate a seperate Mesh Object for each Simple Collision Shape */
|
|
|
|
|
UPROPERTY(EditAnywhere, Category = Options, Meta = (EditCondition = "CollisionType == EExtractCollisionOutputType::Simple"))
|
|
|
|
|
bool bOutputSeparateMeshes = true;
|
|
|
|
|
|
|
|
|
|
/** Show/Hide a preview of the generated mesh (overlaps source mesh) */
|
|
|
|
|
UPROPERTY(EditAnywhere, Category = Options)
|
|
|
|
|
bool bShowPreview = false;
|
|
|
|
|
|
|
|
|
|
/** Show/Hide input mesh */
|
|
|
|
|
UPROPERTY(EditAnywhere, Category = Options)
|
|
|
|
|
bool bShowInputMesh = true;
|
|
|
|
|
};
|
|
|
|
|
|
2020-09-01 14:07:48 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Mesh Inspector Tool for visualizing mesh information
|
|
|
|
|
*/
|
|
|
|
|
UCLASS()
|
2021-07-29 20:08:48 -04:00
|
|
|
class MESHMODELINGTOOLSEXP_API UExtractCollisionGeometryTool : public USingleSelectionMeshEditingTool
|
2020-09-01 14:07:48 -04:00
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
public:
|
|
|
|
|
virtual void Setup() override;
|
2022-01-28 18:40:54 -05:00
|
|
|
virtual void OnShutdown(EToolShutdownType ShutdownType) override;
|
2020-09-01 14:07:48 -04:00
|
|
|
|
|
|
|
|
virtual void OnTick(float DeltaTime) override;
|
|
|
|
|
|
|
|
|
|
virtual bool HasCancel() const override { return true; }
|
|
|
|
|
virtual bool HasAccept() const override { return true; }
|
|
|
|
|
virtual bool CanAccept() const override;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
2021-06-22 02:09:15 -04:00
|
|
|
/** Property set for type of output object (StaticMesh, Volume, etc) */
|
|
|
|
|
UPROPERTY()
|
2021-07-20 00:24:38 -04:00
|
|
|
TObjectPtr<UCreateMeshObjectTypeProperties> OutputTypeProperties;
|
2021-06-22 02:09:15 -04:00
|
|
|
|
|
|
|
|
UPROPERTY()
|
2021-07-20 00:24:38 -04:00
|
|
|
TObjectPtr<UExtractCollisionToolProperties> Settings;
|
2021-06-22 02:09:15 -04:00
|
|
|
|
2020-09-01 14:07:48 -04:00
|
|
|
UPROPERTY()
|
2021-07-20 00:24:38 -04:00
|
|
|
TObjectPtr<UCollisionGeometryVisualizationProperties> VizSettings = nullptr;
|
2020-09-01 14:07:48 -04:00
|
|
|
|
|
|
|
|
UPROPERTY()
|
2021-07-20 00:24:38 -04:00
|
|
|
TObjectPtr<UPhysicsObjectToolPropertySet> ObjectProps;
|
2020-09-01 14:07:48 -04:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
UPROPERTY()
|
2021-07-20 00:24:38 -04:00
|
|
|
TObjectPtr<UPreviewGeometry> PreviewElements;
|
2020-09-01 14:07:48 -04:00
|
|
|
|
|
|
|
|
UPROPERTY()
|
2021-07-20 00:24:38 -04:00
|
|
|
TObjectPtr<UPreviewMesh> PreviewMesh;
|
2020-09-01 14:07:48 -04:00
|
|
|
|
|
|
|
|
// these are TSharedPtr because TPimplPtr cannot currently be added to a TArray?
|
|
|
|
|
TSharedPtr<FPhysicsDataCollection> PhysicsInfo;
|
|
|
|
|
|
2021-11-26 16:37:25 -05:00
|
|
|
TArray<TSharedPtr<UE::Geometry::FDynamicMesh3>> CurrentMeshParts;
|
2021-03-09 19:33:56 -04:00
|
|
|
UE::Geometry::FDynamicMesh3 CurrentMesh;
|
2020-09-01 14:07:48 -04:00
|
|
|
bool bResultValid = false;
|
2021-06-22 02:09:15 -04:00
|
|
|
void RecalculateMesh_Simple();
|
|
|
|
|
void RecalculateMesh_Complex();
|
2020-09-01 14:07:48 -04:00
|
|
|
|
|
|
|
|
bool bVisualizationDirty = false;
|
|
|
|
|
void UpdateVisualization();
|
|
|
|
|
};
|