You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb none #rnx #jira none #preflight 60c52c5db9446100014da02d [CL 16653115 by Ryan Schmidt in ue5-main branch]
111 lines
2.9 KiB
C++
111 lines
2.9 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
#include "ConversionUtils/DynamicMeshToVolume.h"
|
|
#include "GameFramework/Volume.h"
|
|
#include "Engine/Classes/Engine/BlockingVolume.h"
|
|
#include "SingleSelectionTool.h"
|
|
#include "InteractiveToolBuilder.h"
|
|
#include "DynamicMesh/DynamicMesh3.h"
|
|
#include "PreviewMesh.h"
|
|
#include "Drawing/LineSetComponent.h"
|
|
#include "PropertySets/OnAcceptProperties.h"
|
|
#include "BaseTools/SingleSelectionMeshEditingTool.h"
|
|
#include "MeshToVolumeTool.generated.h"
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UCLASS()
|
|
class MESHMODELINGTOOLSEDITORONLY_API UMeshToVolumeToolBuilder : public USingleSelectionMeshEditingToolBuilder
|
|
{
|
|
GENERATED_BODY()
|
|
public:
|
|
virtual bool CanBuildTool(const FToolBuilderState & SceneState) const override;
|
|
virtual USingleSelectionMeshEditingTool* CreateNewTool(const FToolBuilderState & SceneState) const override;
|
|
};
|
|
|
|
|
|
|
|
|
|
UENUM()
|
|
enum class EMeshToVolumeMode
|
|
{
|
|
/** Create a separate Volume Face for each Triangle */
|
|
TriangulatePolygons,
|
|
/** Create Volume Faces based on Planar Polygons */
|
|
MinimalPolygons
|
|
};
|
|
|
|
|
|
|
|
UCLASS()
|
|
class MESHMODELINGTOOLSEDITORONLY_API UMeshToVolumeToolProperties : public UInteractiveToolPropertySet
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
/** Method for converting the input mesh to a set of Planar Polygonal Faces in the output Volume. */
|
|
UPROPERTY(EditAnywhere, Category = ConversionOptions)
|
|
EMeshToVolumeMode ConversionMode = EMeshToVolumeMode::MinimalPolygons;
|
|
|
|
/** Type of new Volume to create on Accept */
|
|
UPROPERTY(EditAnywhere, Category = NewVolume, meta = (EditCondition = "TargetVolume == nullptr") )
|
|
TSubclassOf<class AVolume> NewVolumeType = ABlockingVolume::StaticClass();
|
|
|
|
/** If set, the target Volume will be updated, rather than creating a new Volume. */
|
|
UPROPERTY(EditAnywhere, Category = UpdateExisting)
|
|
TLazyObjectPtr<AVolume> TargetVolume;
|
|
};
|
|
|
|
|
|
/**
|
|
* Converts a mesh to a volume.
|
|
*
|
|
* Note: If ConversionUtils/DynamicMeshToVolume is rewritten to be safe for runtime, this
|
|
* tool can be moved out of the editor-only section and put with VolumeToMeshTool.
|
|
*/
|
|
UCLASS()
|
|
class MESHMODELINGTOOLSEDITORONLY_API UMeshToVolumeTool : public USingleSelectionMeshEditingTool
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
UMeshToVolumeTool();
|
|
|
|
virtual void Setup() override;
|
|
virtual void Shutdown(EToolShutdownType ShutdownType) override;
|
|
|
|
virtual void Render(IToolsContextRenderAPI* RenderAPI) override;
|
|
virtual void OnTick(float DeltaTime) override;
|
|
|
|
virtual bool HasCancel() const override { return true; }
|
|
virtual bool HasAccept() const override { return true; }
|
|
|
|
protected:
|
|
UPROPERTY()
|
|
UMeshToVolumeToolProperties* Settings;
|
|
|
|
UPROPERTY()
|
|
UOnAcceptHandleSourcesProperties* HandleSourcesProperties;
|
|
|
|
UPROPERTY()
|
|
UPreviewMesh* PreviewMesh;
|
|
|
|
UPROPERTY()
|
|
ULineSetComponent* VolumeEdgesSet;
|
|
|
|
protected:
|
|
UE::Geometry::FDynamicMesh3 InputMesh;
|
|
|
|
void RecalculateVolume();
|
|
void UpdateLineSet();
|
|
|
|
bool bVolumeValid = false;
|
|
TArray<UE::Conversion::FDynamicMeshFace> Faces;
|
|
|
|
};
|