You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Added PhysicalMaterialMasks.
#jira UE-1949, UE1950 #rb matt.kuhlenschmidt, benn.gallagher #ROBOMERGE-SOURCE: CL 11112514 via CL 11112515 #ROBOMERGE-BOT: (v640-11091645) [CL 11112518 by christina tempelaarl in Main branch]
This commit is contained in:
@@ -81,6 +81,7 @@
|
||||
#include "AssetTypeActions/AssetTypeActions_ObjectLibrary.h"
|
||||
#include "AssetTypeActions/AssetTypeActions_ParticleSystem.h"
|
||||
#include "AssetTypeActions/AssetTypeActions_PhysicalMaterial.h"
|
||||
#include "AssetTypeActions/AssetTypeActions_PhysicalMaterialMask.h"
|
||||
#include "AssetTypeActions/AssetTypeActions_PhysicsAsset.h"
|
||||
#include "AssetTypeActions/AssetTypeActions_PoseAsset.h"
|
||||
#include "AssetTypeActions/AssetTypeActions_PreviewMeshCollection.h"
|
||||
@@ -239,6 +240,7 @@ UAssetToolsImpl::UAssetToolsImpl(const FObjectInitializer& ObjectInitializer)
|
||||
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_ObjectLibrary));
|
||||
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_ParticleSystem));
|
||||
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_PhysicalMaterial));
|
||||
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_PhysicalMaterialMask));
|
||||
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_PhysicsAsset));
|
||||
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_PreviewMeshCollection));
|
||||
RegisterAssetTypeActions(MakeShareable(new FAssetTypeActions_ProceduralFoliageSpawner(FoliageCategoryBit)));
|
||||
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "AssetTypeActions/AssetTypeActions_PhysicalMaterialMask.h"
|
||||
#include "PhysicalMaterials/PhysicalMaterialMask.h"
|
||||
#include "PhysicalMaterialMaskImport.h"
|
||||
#include "EditorFramework/AssetImportData.h"
|
||||
#include "Editor.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
#include "Engine/Texture.h"
|
||||
#include "PhysicalMaterialMaskImport.h"
|
||||
#include "HAL/PlatformApplicationMisc.h"
|
||||
#include "HAL/FileManager.h"
|
||||
#include "ToolMenus.h"
|
||||
#include "Misc/MessageDialog.h"
|
||||
#include "Misc/FeedbackContext.h"
|
||||
#include "Misc/FileHelper.h"
|
||||
#include "Misc/Paths.h"
|
||||
#include "Framework/Application/SlateApplication.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "AssetTypeActions"
|
||||
|
||||
DEFINE_LOG_CATEGORY_STATIC(LogAssetTypeActionsPhysicalMaterialMask, Log, All);
|
||||
|
||||
UClass* FAssetTypeActions_PhysicalMaterialMask::GetSupportedClass() const
|
||||
{
|
||||
return UPhysicalMaterialMask::StaticClass();
|
||||
}
|
||||
|
||||
void FAssetTypeActions_PhysicalMaterialMask::GetActions(const TArray<UObject*>& InObjects, FToolMenuSection& Section)
|
||||
{
|
||||
TArray<TWeakObjectPtr<UPhysicalMaterialMask>> SelectedMasks = GetTypedWeakObjectPtrs<UPhysicalMaterialMask>(InObjects);
|
||||
|
||||
TArray<FString> ResolvedFilePaths;
|
||||
GetResolvedSourceFilePaths(InObjects, ResolvedFilePaths);
|
||||
|
||||
if (SelectedMasks.Num() == 1 && ResolvedFilePaths.Num() == 1 && ResolvedFilePaths[0].IsEmpty())
|
||||
{
|
||||
Section.AddMenuEntry(
|
||||
"PhysicalMaterialMask_Import",
|
||||
LOCTEXT("PhysicalMaterialMask_ImportMaskTexture", "Import Mask Texture"),
|
||||
LOCTEXT("PhysicalMaterialMask_ImportMaskTextureTooltip", "Imports a texture to use as a physical material mask."),
|
||||
FSlateIcon(FEditorStyle::GetStyleSetName(), "ClassIcon.Material"),
|
||||
FUIAction(
|
||||
FExecuteAction::CreateSP(this, &FAssetTypeActions_PhysicalMaterialMask::ExecuteImport, SelectedMasks[0]),
|
||||
FCanExecuteAction()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void FAssetTypeActions_PhysicalMaterialMask::GetResolvedSourceFilePaths(const TArray<UObject*>& TypeAssets, TArray<FString>& OutSourceFilePaths) const
|
||||
{
|
||||
for (auto& Asset : TypeAssets)
|
||||
{
|
||||
TArray<FString> ExtractedFilenames;
|
||||
UPhysicalMaterialMask* PhysMatMask = CastChecked<UPhysicalMaterialMask>(Asset);
|
||||
if (UAssetImportData* AssetImportData = PhysMatMask->AssetImportData)
|
||||
{
|
||||
if (AssetImportData->GetSourceFileCount() > 0)
|
||||
{
|
||||
if (!AssetImportData->GetSourceData().SourceFiles[0].RelativeFilename.IsEmpty())
|
||||
{
|
||||
PhysMatMask->AssetImportData->ExtractFilenames(ExtractedFilenames);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ExtractedFilenames.Num() > 0)
|
||||
{
|
||||
OutSourceFilePaths.Emplace(ExtractedFilenames[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
OutSourceFilePaths.Emplace(FString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class UThumbnailInfo* FAssetTypeActions_PhysicalMaterialMask::GetThumbnailInfo(UObject* Asset) const
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
EThumbnailPrimType FAssetTypeActions_PhysicalMaterialMask::GetDefaultThumbnailPrimitiveType(UObject* Asset) const
|
||||
{
|
||||
return TPT_Sphere;
|
||||
}
|
||||
|
||||
bool FAssetTypeActions_PhysicalMaterialMask::CanExecuteImportedAssetActions(const TArray<FString> ResolvedFilePaths) const
|
||||
{
|
||||
// Verify that all the file paths are legitimate
|
||||
for (const auto& SourceFilePath : ResolvedFilePaths)
|
||||
{
|
||||
if (!SourceFilePath.Len() || IFileManager::Get().FileSize(*SourceFilePath) == INDEX_NONE)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FAssetTypeActions_PhysicalMaterialMask::ExecuteImport(TWeakObjectPtr<UPhysicalMaterialMask> SelectedMask)
|
||||
{
|
||||
if (UPhysicalMaterialMask* PhysMatMask = SelectedMask.Get())
|
||||
{
|
||||
FPhysicalMaterialMaskImport::ImportMaskTexture(PhysMatMask);
|
||||
}
|
||||
}
|
||||
|
||||
void FAssetTypeActions_PhysicalMaterialMask::ExecuteReimport(TArray<TWeakObjectPtr<UPhysicalMaterialMask>> SelectedMasks)
|
||||
{
|
||||
for (TWeakObjectPtr<UPhysicalMaterialMask> SelectedMask : SelectedMasks)
|
||||
{
|
||||
if (UPhysicalMaterialMask* PhysMatMask = SelectedMask.Get())
|
||||
{
|
||||
FPhysicalMaterialMaskImport::ReimportMaskTexture(PhysMatMask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FAssetTypeActions_PhysicalMaterialMask::ExecuteReimportWithNewFile(TWeakObjectPtr<UPhysicalMaterialMask> SelectedMask)
|
||||
{
|
||||
if (UPhysicalMaterialMask* PhysMatMask = SelectedMask.Get())
|
||||
{
|
||||
FPhysicalMaterialMaskImport::ReimportMaskTextureWithNewFile(PhysMatMask);
|
||||
}
|
||||
}
|
||||
|
||||
void FAssetTypeActions_PhysicalMaterialMask::ExecuteOpenSourceLocation(const TArray<FString> ResolvedFilePaths)
|
||||
{
|
||||
// Open all files in the explorer
|
||||
for (const auto& SourceFilePath : ResolvedFilePaths)
|
||||
{
|
||||
FPlatformProcess::ExploreFolder(*FPaths::GetPath(SourceFilePath));
|
||||
}
|
||||
}
|
||||
|
||||
void FAssetTypeActions_PhysicalMaterialMask::ExecuteOpenInExternalEditor(const TArray<FString> ResolvedFilePaths)
|
||||
{
|
||||
// Open all files in their respective editor
|
||||
for (const auto& SourceFilePath : ResolvedFilePaths)
|
||||
{
|
||||
FPlatformProcess::LaunchFileInDefaultExternalApplication(*SourceFilePath, NULL, ELaunchVerb::Edit);
|
||||
}
|
||||
}
|
||||
|
||||
void FAssetTypeActions_PhysicalMaterialMask::ExecuteDebug(TWeakObjectPtr<UPhysicalMaterialMask> SelectedMask)
|
||||
{
|
||||
if (UPhysicalMaterialMask* PhysMatMask = SelectedMask.Get())
|
||||
{
|
||||
PhysMatMask->DumpMaskData();
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AssetTypeActions_Base.h"
|
||||
|
||||
class FAssetTypeActions_PhysicalMaterialMask : public FAssetTypeActions_Base
|
||||
{
|
||||
public:
|
||||
// IAssetTypeActions Implementation
|
||||
virtual FText GetName() const override { return NSLOCTEXT("AssetTypeActions", "AssetTypeActions_PhysicalMaterialMask", "Physical Material Mask"); }
|
||||
virtual FColor GetTypeColor() const override { return FColor(200,162,108); }
|
||||
virtual UClass* GetSupportedClass() const override;
|
||||
virtual bool HasActions(const TArray<UObject*>& InObjects) const override { return true; }
|
||||
virtual void GetActions(const TArray<UObject*>& InObjects, struct FToolMenuSection& Section) override;
|
||||
virtual uint32 GetCategories() override { return EAssetTypeCategories::Physics; }
|
||||
virtual bool IsImportedAsset() const override { return true; }
|
||||
virtual void GetResolvedSourceFilePaths(const TArray<UObject*>& TypeAssets, TArray<FString>& OutSourceFilePaths) const override;
|
||||
|
||||
/** Returns the thumbnail info for the specified asset, if it has one. */
|
||||
virtual class UThumbnailInfo* GetThumbnailInfo(UObject* Asset) const override;
|
||||
|
||||
/** Returns the default thumbnail type that should be rendered when rendering primitive shapes. This does not need to be implemented if the asset does not render a primitive shape */
|
||||
virtual EThumbnailPrimType GetDefaultThumbnailPrimitiveType(UObject* Asset) const override;
|
||||
|
||||
private:
|
||||
/** Handler to check to see if imported asset actions are allowed */
|
||||
bool CanExecuteImportedAssetActions(const TArray<FString> ResolvedFilePaths) const;
|
||||
|
||||
/** Handler for Import */
|
||||
void ExecuteImport(TWeakObjectPtr<UPhysicalMaterialMask> InSelectedMask);
|
||||
|
||||
/** Handler for Reimport */
|
||||
void ExecuteReimport(TArray<TWeakObjectPtr<UPhysicalMaterialMask>> InSelectedMasks);
|
||||
|
||||
/** Handler for ReimportWithNewFile */
|
||||
void ExecuteReimportWithNewFile(TWeakObjectPtr<UPhysicalMaterialMask> InSelectedMask);
|
||||
|
||||
/** Handler for OpenSourceLocation */
|
||||
void ExecuteOpenSourceLocation(const TArray<FString> ResolvedFilePaths);
|
||||
|
||||
/** Handler for OpenInExternalEditor */
|
||||
void ExecuteOpenInExternalEditor(const TArray<FString> ResolvedFilePaths);
|
||||
|
||||
/** Handler for Debug */
|
||||
void ExecuteDebug(TWeakObjectPtr<UPhysicalMaterialMask> InSelectedMask);
|
||||
};
|
||||
Reference in New Issue
Block a user