Files
AdricEpic 473f754908 - Registration Race Condition Fixes (Attempt #2 w/ cook fixes)
- Part 1/2 fixing inconsistent file naming that is causing code query tool slowdowns (2/2 will be deprecating old MetasoundFrontendRegistries.h header path)
- Replace SoftObjectPaths with TopLevelAssetPaths for perf (ObjPaths do string copies all over, TopLevelAssetPaths are just two FNames)
#rb helen.yang
#rnx
[FYI] sondra.moyls
#tests AudioQA/EngineTest MetaSound Automated Tests, AudioTests, cook WindowsClient, submit and backout and then fix those problems
#jira UE-198785

[CL 30354102 by AdricEpic in ue5-main branch]
2023-12-15 13:21:12 -05:00

186 lines
6.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "EdGraph/EdGraph.h"
#include "MetasoundAssetBase.h"
#include "MetasoundDocumentInterface.h"
#include "MetasoundFrontend.h"
#include "MetasoundFrontendDocument.h"
#include "MetasoundFrontendTransform.h"
#include "MetasoundOperatorSettings.h"
#include "MetasoundRouter.h"
#include "MetasoundUObjectRegistry.h"
#include "Serialization/Archive.h"
#include "UObject/ObjectSaveContext.h"
#include "UObject/SoftObjectPath.h"
#include "Metasound.generated.h"
UCLASS(Abstract)
class METASOUNDENGINE_API UMetasoundEditorGraphBase : public UEdGraph
{
GENERATED_BODY()
public:
virtual bool IsEditorOnly() const override { return true; }
virtual bool NeedsLoadForEditorGame() const override { return false; }
virtual void RegisterGraphWithFrontend() PURE_VIRTUAL(UMetasoundEditorGraphBase::RegisterGraphWithFrontend(), )
#if WITH_EDITORONLY_DATA
virtual FMetasoundFrontendDocumentModifyContext& GetModifyContext() PURE_VIRTUAL(UMetasoundEditorGraphBase::GetModifyContext, static FMetasoundFrontendDocumentModifyContext InvalidModifyData; return InvalidModifyData; )
virtual const FMetasoundFrontendDocumentModifyContext& GetModifyContext() const PURE_VIRTUAL(UMetasoundEditorGraphBase::GetModifyContext, static const FMetasoundFrontendDocumentModifyContext InvalidModifyData; return InvalidModifyData; )
virtual void ClearVersionedOnLoad() PURE_VIRTUAL(UMetasoundEditorGraphBase::ClearVersionedOnLoad, )
virtual bool GetVersionedOnLoad() const PURE_VIRTUAL(UMetasoundEditorGraphBase::GetVersionedOnLoad, return false; )
virtual void SetVersionedOnLoad() PURE_VIRTUAL(UMetasoundEditorGraphBase::SetVersionedOnLoad, )
#endif // WITH_EDITORONLY_DATA
int32 GetHighestMessageSeverity() const;
};
namespace Metasound
{
// Forward declare
struct FMetaSoundEngineAssetHelper;
}
/**
* This asset type is used for Metasound assets that can only be used as nodes in other Metasound graphs.
* Because of this, they contain no required inputs or outputs.
*/
UCLASS(hidecategories = object, BlueprintType)
class METASOUNDENGINE_API UMetaSoundPatch : public UObject, public FMetasoundAssetBase, public IMetaSoundDocumentInterface
{
GENERATED_BODY()
friend struct Metasound::FMetaSoundEngineAssetHelper;
protected:
UPROPERTY(EditAnywhere, Category = CustomView)
FMetasoundFrontendDocument RootMetaSoundDocument;
UPROPERTY()
TSet<FString> ReferencedAssetClassKeys;
UPROPERTY()
TSet<TObjectPtr<UObject>> ReferencedAssetClassObjects;
UPROPERTY()
TSet<FSoftObjectPath> ReferenceAssetClassCache;
#if WITH_EDITORONLY_DATA
UPROPERTY()
TObjectPtr<UMetasoundEditorGraphBase> Graph;
#endif // WITH_EDITORONLY_DATA
public:
UMetaSoundPatch(const FObjectInitializer& ObjectInitializer);
UPROPERTY(AssetRegistrySearchable)
FGuid AssetClassID;
#if WITH_EDITORONLY_DATA
UPROPERTY(AssetRegistrySearchable)
FString RegistryInputTypes;
UPROPERTY(AssetRegistrySearchable)
FString RegistryOutputTypes;
UPROPERTY(AssetRegistrySearchable)
int32 RegistryVersionMajor = 0;
UPROPERTY(AssetRegistrySearchable)
int32 RegistryVersionMinor = 0;
UPROPERTY(AssetRegistrySearchable)
bool bIsPreset = false;
// Sets Asset Registry Metadata associated with this MetaSound
virtual void SetRegistryAssetClassInfo(const Metasound::Frontend::FNodeClassInfo& InClassInfo) override;
// Returns document name (for editor purposes, and avoids making document public for edit
// while allowing editor to reference directly)
static FName GetDocumentPropertyName()
{
return GET_MEMBER_NAME_CHECKED(UMetaSoundPatch, RootMetaSoundDocument);
}
// Name to display in editors
virtual FText GetDisplayName() const override;
// Returns the graph associated with this Metasound. Graph is required to be referenced on
// Metasound UObject for editor serialization purposes.
// @return Editor graph associated with UMetaSoundSource.
virtual UEdGraph* GetGraph() override;
virtual const UEdGraph* GetGraph() const override;
virtual UEdGraph& GetGraphChecked() override;
virtual const UEdGraph& GetGraphChecked() const override;
// Sets the graph associated with this Metasound. Graph is required to be referenced on
// Metasound UObject for editor serialization purposes.
// @param Editor graph associated with UMetaSoundSource.
virtual void SetGraph(UEdGraph* InGraph) override
{
Graph = CastChecked<UMetasoundEditorGraphBase>(InGraph);
}
#endif // #if WITH_EDITORONLY_DATA
virtual FTopLevelAssetPath GetAssetPathChecked() const override;
virtual const UClass& GetBaseMetaSoundUClass() const final override;
virtual const FMetasoundFrontendDocument& GetConstDocument() const override;
#if WITH_EDITOR
virtual void PostDuplicate(EDuplicateMode::Type DuplicateMode) override;
virtual void PostEditUndo() override;
#endif // WITH_EDITOR
virtual void BeginDestroy() override;
virtual void PreSave(FObjectPreSaveContext InSaveContext) override;
virtual void Serialize(FArchive& InArchive) override;
virtual void PostLoad() override;
virtual bool ConformObjectDataToInterfaces() override { return false; }
virtual const TSet<FString>& GetReferencedAssetClassKeys() const override
{
return ReferencedAssetClassKeys;
}
virtual TArray<FMetasoundAssetBase*> GetReferencedAssets() override;
virtual const TSet<FSoftObjectPath>& GetAsyncReferencedAssetClassPaths() const override;
virtual void OnAsyncReferencedAssetsLoaded(const TArray<FMetasoundAssetBase*>& InAsyncReferences) override;
UObject* GetOwningAsset() override
{
return this;
}
const UObject* GetOwningAsset() const override
{
return this;
}
protected:
#if WITH_EDITOR
virtual void SetReferencedAssetClasses(TSet<Metasound::Frontend::IMetaSoundAssetManager::FAssetInfo>&& InAssetClasses) override;
#endif // #if WITH_EDITOR
Metasound::Frontend::FDocumentAccessPtr GetDocumentAccessPtr() override;
Metasound::Frontend::FConstDocumentAccessPtr GetDocumentConstAccessPtr() const override;
private:
virtual FMetasoundFrontendDocument& GetDocument() override
{
return RootMetaSoundDocument;
}
virtual bool IsBuilderActive() const override;
virtual void OnBeginActiveBuilder() override;
virtual void OnFinishActiveBuilder() override;
bool bIsBuilderActive = false;
};