MeshModelingToolset: Cleanup UV Unwrap tool

#rb ryan.schmidt
#preflight 61a6d63b6c7d8a7295f405a2, 61a92f32fc3f6823e8d2bac7

#ROBOMERGE-AUTHOR: michael.balzer
#ROBOMERGE-SOURCE: CL 18357442 in //UE5/Release-5.0/... via CL 18357499
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469)

[CL 18357514 by michael balzer in ue5-release-engine-test branch]
This commit is contained in:
michael balzer
2021-12-02 15:47:10 -05:00
parent a518e290ca
commit 4a4e360ab1
8 changed files with 98 additions and 97 deletions
@@ -0,0 +1,46 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "InteractiveTool.h"
#include "GeometryBase.h"
#include "MeshUVChannelProperties.generated.h"
struct FMeshDescription;
PREDECLARE_USE_GEOMETRY_CLASS(FDynamicMesh3);
UCLASS()
class MESHMODELINGTOOLS_API UMeshUVChannelProperties : public UInteractiveToolPropertySet
{
GENERATED_BODY()
public:
/** Select UV channel in the mesh */
UPROPERTY(EditAnywhere, Category = "UV Channel", meta = (DisplayName = "UV Channel", GetOptions = GetUVChannelNamesFunc, NoResetToDefault))
FString UVChannel;
UFUNCTION()
const TArray<FString>& GetUVChannelNamesFunc() const;
UPROPERTY(meta = (TransientToolProperty))
TArray<FString> UVChannelNamesList;
void Initialize(int32 NumUVChannels, bool bInitializeSelection = true);
void Initialize(const FMeshDescription* MeshDescription, bool bInitializeSelection = true);
void Initialize(const FDynamicMesh3* Mesh, bool bInitializeSelection = true);
/**
* Verify that the UV channel selection is valid
* @param bUpdateIfInvalid if selection is not valid, reset UVChannel to UV0 or empty if no UV channels exist
* @return true if selection in UVChannel is an entry in UVChannelNamesList.
*/
bool ValidateSelection(bool bUpdateIfInvalid);
/**
* @param bForceToZeroOnFailure if true, then instead of returning -1 we return 0 so calling code can fallback to default UV paths
* @return selected UV channel index, or -1 if invalid selection, or 0 if invalid selection and bool bForceToZeroOnFailure = true
*/
int32 GetSelectedChannelIndex(bool bForceToZeroOnFailure = false);
};
@@ -0,0 +1,93 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "BaseTools/SingleSelectionMeshEditingTool.h"
#include "DynamicMesh/DynamicMesh3.h"
#include "MeshOpPreviewHelpers.h"
#include "Properties/MeshMaterialProperties.h"
#include "Properties/MeshUVChannelProperties.h"
#include "Properties/RecomputeUVsProperties.h"
#include "PropertySets/PolygroupLayersProperties.h"
#include "Polygroups/PolygroupSet.h"
#include "Drawing/UVLayoutPreview.h"
#include "RecomputeUVsTool.generated.h"
// Forward declarations
class UDynamicMeshComponent;
class UMaterialInterface;
class UMaterialInstanceDynamic;
class RecomputeUVsOp;
class URecomputeUVsOpFactory;
/**
*
*/
UCLASS()
class MESHMODELINGTOOLS_API URecomputeUVsToolBuilder : public USingleSelectionMeshEditingToolBuilder
{
GENERATED_BODY()
public:
virtual USingleSelectionMeshEditingTool* CreateNewTool(const FToolBuilderState& SceneState) const override;
};
/**
* URecomputeUVsTool Recomputes UVs based on existing segmentations of the mesh
*/
UCLASS()
class MESHMODELINGTOOLS_API URecomputeUVsTool : public USingleSelectionMeshEditingTool
{
GENERATED_BODY()
public:
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; }
virtual bool CanAccept() const override;
virtual void OnPropertyModified(UObject* PropertySet, FProperty* Property) override;
protected:
UPROPERTY()
TObjectPtr<UMeshUVChannelProperties> UVChannelProperties = nullptr;
UPROPERTY()
TObjectPtr<URecomputeUVsToolProperties> Settings = nullptr;
UPROPERTY()
TObjectPtr<UPolygroupLayersProperties> PolygroupLayerProperties = nullptr;
UPROPERTY()
TObjectPtr<UExistingMeshMaterialProperties> MaterialSettings = nullptr;
UPROPERTY()
bool bCreateUVLayoutViewOnSetup = true;
UPROPERTY()
TObjectPtr<UUVLayoutPreview> UVLayoutView = nullptr;
UPROPERTY()
TObjectPtr<URecomputeUVsOpFactory> RecomputeUVsOpFactory;
UPROPERTY()
TObjectPtr<UMeshOpPreviewWithBackgroundCompute> Preview = nullptr;
TSharedPtr<UE::Geometry::FDynamicMesh3, ESPMode::ThreadSafe> InputMesh;
TSharedPtr<UE::Geometry::FPolygroupSet, ESPMode::ThreadSafe> ActiveGroupSet;
void OnSelectedGroupLayerChanged();
void UpdateActiveGroupLayer();
int32 GetSelectedUVChannel() const;
void OnPreviewMeshUpdated();
};