2021-01-13 10:48:59 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "MetasoundFrontendDocument.h"
|
|
|
|
|
|
2021-07-27 15:36:03 -04:00
|
|
|
#include "Algo/Transform.h"
|
2021-01-13 10:48:59 -04:00
|
|
|
#include "MetasoundFrontend.h"
|
|
|
|
|
#include "MetasoundFrontendRegistries.h"
|
2021-02-10 21:43:31 -04:00
|
|
|
#include "MetasoundLog.h"
|
2021-01-13 10:48:59 -04:00
|
|
|
|
2021-01-28 19:02:51 -04:00
|
|
|
namespace Metasound
|
|
|
|
|
{
|
|
|
|
|
const FGuid FrontendInvalidID = FGuid();
|
2021-07-27 15:36:03 -04:00
|
|
|
|
|
|
|
|
namespace Frontend
|
|
|
|
|
{
|
|
|
|
|
namespace DisplayStyle
|
|
|
|
|
{
|
|
|
|
|
namespace NodeLayout
|
|
|
|
|
{
|
|
|
|
|
const FVector2D DefaultOffsetX { 300.0f, 0.0f };
|
|
|
|
|
const FVector2D DefaultOffsetY { 0.0f, 80.0f };
|
|
|
|
|
} // namespace NodeLayout
|
|
|
|
|
} // namespace DisplayStyle
|
|
|
|
|
} // namespace Frontend
|
2021-01-28 19:02:51 -04:00
|
|
|
}
|
|
|
|
|
|
2021-01-13 10:48:59 -04:00
|
|
|
FMetasoundFrontendNodeInterface::FMetasoundFrontendNodeInterface(const FMetasoundFrontendClassInterface& InClassInterface)
|
|
|
|
|
{
|
|
|
|
|
for (const FMetasoundFrontendClassInput& Input : InClassInterface.Inputs)
|
|
|
|
|
{
|
|
|
|
|
Inputs.Add(Input);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const FMetasoundFrontendClassOutput& Output : InClassInterface.Outputs)
|
|
|
|
|
{
|
|
|
|
|
Outputs.Add(Output);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const FMetasoundFrontendClassEnvironmentVariable& EnvVar : InClassInterface.Environment)
|
|
|
|
|
{
|
|
|
|
|
FMetasoundFrontendVertex EnvVertex;
|
|
|
|
|
EnvVertex.Name = EnvVar.Name;
|
|
|
|
|
EnvVertex.TypeName = EnvVar.TypeName;
|
|
|
|
|
|
|
|
|
|
Environment.Add(MoveTemp(EnvVertex));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FMetasoundFrontendNode::FMetasoundFrontendNode(const FMetasoundFrontendClass& InClass)
|
|
|
|
|
: ClassID(InClass.ID)
|
2021-07-27 15:36:03 -04:00
|
|
|
, Name(InClass.Metadata.GetClassName().Name.ToString())
|
2021-01-13 10:48:59 -04:00
|
|
|
, Interface(InClass.Interface)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-23 20:08:21 -04:00
|
|
|
FString FMetasoundFrontendVersion::ToString() const
|
|
|
|
|
{
|
|
|
|
|
return FString::Format(TEXT("{0} {1}"), { Name.ToString(), Number.ToString() });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FMetasoundFrontendVersion::IsValid() const
|
|
|
|
|
{
|
2021-11-22 15:55:50 -05:00
|
|
|
return Number != GetInvalid().Number && Name != GetInvalid().Name;
|
2021-06-23 20:08:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FMetasoundFrontendVersion& FMetasoundFrontendVersion::GetInvalid()
|
|
|
|
|
{
|
|
|
|
|
static const FMetasoundFrontendVersion InvalidVersion { FName(), FMetasoundFrontendVersionNumber::GetInvalid() };
|
|
|
|
|
return InvalidVersion;
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-13 10:48:59 -04:00
|
|
|
bool FMetasoundFrontendVertex::IsFunctionalEquivalent(const FMetasoundFrontendVertex& InLHS, const FMetasoundFrontendVertex& InRHS)
|
|
|
|
|
{
|
2021-02-24 18:37:19 -04:00
|
|
|
return (InLHS.Name == InRHS.Name) && (InLHS.TypeName == InRHS.TypeName);
|
2021-01-13 10:48:59 -04:00
|
|
|
}
|
|
|
|
|
|
2021-07-27 15:36:03 -04:00
|
|
|
bool FMetasoundFrontendClassVertex::IsFunctionalEquivalent(const FMetasoundFrontendClassVertex& InLHS, const FMetasoundFrontendClassVertex& InRHS)
|
2021-01-13 10:48:59 -04:00
|
|
|
{
|
2021-02-24 18:37:19 -04:00
|
|
|
return FMetasoundFrontendVertex::IsFunctionalEquivalent(InLHS, InRHS);
|
2021-01-13 10:48:59 -04:00
|
|
|
}
|
|
|
|
|
|
2021-01-28 19:02:51 -04:00
|
|
|
FMetasoundFrontendClassName::FMetasoundFrontendClassName(const FName& InNamespace, const FName& InName, const FName& InVariant)
|
|
|
|
|
: Namespace(InNamespace)
|
|
|
|
|
, Name(InName)
|
|
|
|
|
, Variant(InVariant)
|
2021-01-13 10:48:59 -04:00
|
|
|
{
|
2021-01-28 19:02:51 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FMetasoundFrontendClassName::FMetasoundFrontendClassName(const Metasound::FNodeClassName& InName)
|
|
|
|
|
: FMetasoundFrontendClassName(InName.GetNamespace(), InName.GetName(), InName.GetVariant())
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FName FMetasoundFrontendClassName::GetScopedName() const
|
|
|
|
|
{
|
|
|
|
|
return Metasound::FNodeClassName::FormatScopedName(Namespace, Name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FName FMetasoundFrontendClassName::GetFullName() const
|
|
|
|
|
{
|
|
|
|
|
return Metasound::FNodeClassName::FormatFullName(Namespace, Name, Variant);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FString FMetasoundFrontendClassName::ToString() const
|
|
|
|
|
{
|
|
|
|
|
return GetFullName().ToString();
|
2021-01-13 10:48:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool operator==(const FMetasoundFrontendClassName& InLHS, const FMetasoundFrontendClassName& InRHS)
|
|
|
|
|
{
|
|
|
|
|
return (InLHS.Namespace == InRHS.Namespace) && (InLHS.Name == InRHS.Name) && (InLHS.Variant == InRHS.Variant);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-27 15:36:03 -04:00
|
|
|
bool operator!=(const FMetasoundFrontendClassName& InLHS, const FMetasoundFrontendClassName& InRHS)
|
|
|
|
|
{
|
|
|
|
|
return !(InLHS == InRHS);
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-28 19:02:51 -04:00
|
|
|
FMetasoundFrontendClassMetadata::FMetasoundFrontendClassMetadata(const Metasound::FNodeClassMetadata& InNodeClassMetadata)
|
|
|
|
|
: ClassName(InNodeClassMetadata.ClassName)
|
2021-07-27 15:36:03 -04:00
|
|
|
, Version{ InNodeClassMetadata.MajorVersion, InNodeClassMetadata.MinorVersion }
|
2021-01-28 19:02:51 -04:00
|
|
|
, Type(EMetasoundFrontendClassType::External)
|
|
|
|
|
, DisplayName(InNodeClassMetadata.DisplayName)
|
|
|
|
|
, Description(InNodeClassMetadata.Description)
|
|
|
|
|
, PromptIfMissing(InNodeClassMetadata.PromptIfMissing)
|
|
|
|
|
, Author(InNodeClassMetadata.Author)
|
|
|
|
|
, Keywords(InNodeClassMetadata.Keywords)
|
|
|
|
|
, CategoryHierarchy(InNodeClassMetadata.CategoryHierarchy)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-13 10:48:59 -04:00
|
|
|
FMetasoundFrontendClassInput::FMetasoundFrontendClassInput(const FMetasoundFrontendClassVertex& InOther)
|
|
|
|
|
: FMetasoundFrontendClassVertex(InOther)
|
|
|
|
|
{
|
2021-08-19 09:59:27 -04:00
|
|
|
using namespace Metasound::Frontend;
|
|
|
|
|
|
|
|
|
|
EMetasoundFrontendLiteralType DefaultType = GetMetasoundFrontendLiteralType(IDataTypeRegistry::Get().GetDesiredLiteralType(InOther.TypeName));
|
2021-01-13 10:48:59 -04:00
|
|
|
|
2021-02-24 18:37:19 -04:00
|
|
|
DefaultLiteral.SetType(DefaultType);
|
2021-01-13 10:48:59 -04:00
|
|
|
}
|
|
|
|
|
|
2021-05-28 14:09:45 -04:00
|
|
|
FMetasoundFrontendClassVariable::FMetasoundFrontendClassVariable(const FMetasoundFrontendClassVertex& InOther)
|
|
|
|
|
: FMetasoundFrontendClassVertex(InOther)
|
|
|
|
|
{
|
2021-08-19 09:59:27 -04:00
|
|
|
using namespace Metasound::Frontend;
|
|
|
|
|
|
|
|
|
|
EMetasoundFrontendLiteralType DefaultType = GetMetasoundFrontendLiteralType(IDataTypeRegistry::Get().GetDesiredLiteralType(InOther.TypeName));
|
2021-05-28 14:09:45 -04:00
|
|
|
|
|
|
|
|
DefaultLiteral.SetType(DefaultType);
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-13 10:48:59 -04:00
|
|
|
FMetasoundFrontendGraphClass::FMetasoundFrontendGraphClass()
|
|
|
|
|
{
|
2021-07-27 15:36:03 -04:00
|
|
|
Metadata.SetType(EMetasoundFrontendClassType::Graph);
|
2021-01-13 10:48:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FMetasoundFrontendDocument::FMetasoundFrontendDocument()
|
|
|
|
|
{
|
2021-01-20 17:26:40 -04:00
|
|
|
RootGraph.ID = FGuid::NewGuid();
|
2021-07-27 15:36:03 -04:00
|
|
|
RootGraph.Metadata.SetType(EMetasoundFrontendClassType::Graph);
|
2021-06-23 20:08:21 -04:00
|
|
|
ArchetypeVersion = FMetasoundFrontendVersion::GetInvalid();
|
2021-01-13 10:48:59 -04:00
|
|
|
}
|