You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb phil.popp #jira UEAU-710 #ROBOMERGE-SOURCE: CL 15511803 in //UE5/Release-5.0-EarlyAccess/... #ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v771-15082668) [CL 15511819 by rob gay in ue5-main branch]
70 lines
1.8 KiB
C++
70 lines
1.8 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "MetasoundFrontendTransform.h"
|
|
|
|
namespace Metasound
|
|
{
|
|
namespace Frontend
|
|
{
|
|
bool FMatchRootGraphToArchetype::Transform(FDocumentHandle InDocument) const
|
|
{
|
|
if (!InDocument->IsValid())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool bDidEdit = false;
|
|
FGraphHandle Graph = InDocument->GetRootGraph();
|
|
|
|
TArray<FMetasoundFrontendClassInput> RequiredInputs = InDocument->GetRequiredInputs();
|
|
TArray<FMetasoundFrontendClassOutput> RequiredOutputs = InDocument->GetRequiredOutputs();
|
|
|
|
// Go through each input and add or swap if something is missing.
|
|
for (const FMetasoundFrontendClassInput& RequiredInput : RequiredInputs)
|
|
{
|
|
const FMetasoundFrontendClassInput* ClassInput = Graph->FindClassInputWithName(RequiredInput.Name).Get();
|
|
|
|
bool bIsMatching = false;
|
|
if (nullptr != ClassInput)
|
|
{
|
|
bIsMatching = FMetasoundFrontendClassVertex::IsFunctionalEquivalent(RequiredInput, *ClassInput);
|
|
}
|
|
|
|
if (!bIsMatching)
|
|
{
|
|
bDidEdit = true;
|
|
if (nullptr != ClassInput)
|
|
{
|
|
Graph->RemoveInputVertex(RequiredInput.Name);
|
|
}
|
|
Graph->AddInputVertex(RequiredInput);
|
|
}
|
|
}
|
|
|
|
// Go through each output and add or swap if something is missing.
|
|
for (const FMetasoundFrontendClassOutput& RequiredOutput : RequiredOutputs)
|
|
{
|
|
const FMetasoundFrontendClassOutput* ClassOutput = Graph->FindClassOutputWithName(RequiredOutput.Name).Get();
|
|
|
|
bool bIsMatching = false;
|
|
if (nullptr != ClassOutput)
|
|
{
|
|
bIsMatching = FMetasoundFrontendClassVertex::IsFunctionalEquivalent(RequiredOutput, *ClassOutput);
|
|
}
|
|
|
|
if (!bIsMatching)
|
|
{
|
|
bDidEdit = true;
|
|
if (nullptr != ClassOutput)
|
|
{
|
|
Graph->RemoveOutputVertex(RequiredOutput.Name);
|
|
}
|
|
Graph->AddOutputVertex(RequiredOutput);
|
|
}
|
|
}
|
|
|
|
return bDidEdit;
|
|
}
|
|
}
|
|
}
|