2022-08-12 14:22:05 -04:00
// Copyright Epic Games, Inc. All Rights Reserved.
# include "NodeTemplates/MetasoundFrontendNodeTemplateReroute.h"
2022-08-16 16:19:43 -04:00
# include "Algo/AnyOf.h"
2023-09-07 11:11:22 -04:00
# include "MetasoundAssetManager.h"
2022-08-12 14:22:05 -04:00
# include "MetasoundFrontendDataTypeRegistry.h"
2024-03-07 17:53:25 -05:00
# include "MetasoundFrontendDocument.h"
2023-09-05 17:54:02 -04:00
# include "MetasoundFrontendDocumentBuilder.h"
2023-09-07 11:11:22 -04:00
# include "MetasoundFrontendNodeTemplateRegistry.h"
2022-08-12 14:22:05 -04:00
# include "MetasoundFrontendRegistries.h"
2024-03-07 17:53:25 -05:00
# include "MetasoundFrontendTransform.h"
2022-08-12 14:22:05 -04:00
2023-09-05 17:54:02 -04:00
namespace Metasound : : Frontend
2022-08-12 14:22:05 -04:00
{
2023-09-05 17:54:02 -04:00
namespace ReroutePrivate
2022-08-12 14:22:05 -04:00
{
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
class FRerouteNodeTemplateTransform : public INodeTemplateTransform
2022-08-12 14:22:05 -04:00
{
2023-09-05 17:54:02 -04:00
public :
2023-09-06 12:54:02 -04:00
FRerouteNodeTemplateTransform ( ) = default ;
virtual ~ FRerouteNodeTemplateTransform ( ) = default ;
2022-08-16 16:19:43 -04:00
2024-06-27 18:32:11 -04:00
virtual bool Transform ( const FGuid & InPageID , const FGuid & InNodeID , FMetaSoundFrontendDocumentBuilder & OutBuilder ) const override ;
2023-09-05 17:54:02 -04:00
} ;
2022-08-16 16:19:43 -04:00
2024-06-27 18:32:11 -04:00
bool FRerouteNodeTemplateTransform : : Transform ( const FGuid & InPageID , const FGuid & InNodeID , FMetaSoundFrontendDocumentBuilder & OutBuilder ) const
2022-08-12 14:22:05 -04:00
{
2023-09-06 12:54:02 -04:00
FMetasoundFrontendEdge InputEdge ;
TArray < FMetasoundFrontendEdge > OutputEdges ;
2024-06-27 18:32:11 -04:00
const FMetasoundFrontendNode * Node = OutBuilder . FindNode ( InNodeID , & InPageID ) ;
2023-09-07 11:11:22 -04:00
if ( ensureMsgf ( Node , TEXT ( " Failed to find node with ID '%s' when reroute template node transform was given a valid ID for builder '%s'. " ) ,
* InNodeID . ToString ( ) ,
* OutBuilder . GetDebugName ( ) ) )
2022-08-12 14:22:05 -04:00
{
2023-09-07 11:11:22 -04:00
if ( ! ensureMsgf ( Node - > Interface . Inputs . Num ( ) = = 1 , TEXT ( " Reroute nodes must only have one input " ) ) )
2023-09-05 17:54:02 -04:00
{
return false ;
}
2022-08-12 14:22:05 -04:00
2023-09-07 11:11:22 -04:00
if ( ! ensureMsgf ( Node - > Interface . Outputs . Num ( ) = = 1 , TEXT ( " Reroute nodes must only have one output " ) ) )
2023-09-05 17:54:02 -04:00
{
return false ;
}
2023-09-06 12:54:02 -04:00
// Copy input edge to mutate from fields and avoid pointer going out of scope when template node is removed below
{
const FMetasoundFrontendVertex & InputVertex = Node - > Interface . Inputs . Last ( ) ;
2024-06-27 18:32:11 -04:00
TArray < const FMetasoundFrontendEdge * > InputEdges = OutBuilder . FindEdges ( Node - > GetID ( ) , InputVertex . VertexID , & InPageID ) ;
2023-09-06 12:54:02 -04:00
if ( ! InputEdges . IsEmpty ( ) )
{
InputEdge = * InputEdges . Last ( ) ;
}
}
// Copy output edges to mutate from fields and avoid pointer going out of scope when swapping below
{
const FMetasoundFrontendVertex & OutputVertex = Node - > Interface . Outputs . Last ( ) ;
2024-06-27 18:32:11 -04:00
TArray < const FMetasoundFrontendEdge * > CurrentOutputEdges = OutBuilder . FindEdges ( Node - > GetID ( ) , OutputVertex . VertexID , & InPageID ) ;
2023-09-06 12:54:02 -04:00
Algo : : Transform ( CurrentOutputEdges , OutputEdges , [ ] ( const FMetasoundFrontendEdge * CurrentEdge )
{
check ( CurrentEdge ) ;
return * CurrentEdge ;
} ) ;
}
// Remove the template node
2024-06-27 18:32:11 -04:00
OutBuilder . RemoveNode ( Node - > GetID ( ) , & InPageID ) ;
2023-09-05 17:54:02 -04:00
2023-09-07 11:11:22 -04:00
// Add new connections from reroute source node to reroute destination node. Either could be another reroute,
// which is valid because said node will subsequently get processed.
if ( InputEdge . GetFromVertexHandle ( ) . IsSet ( ) )
2023-09-05 17:54:02 -04:00
{
2023-09-07 11:11:22 -04:00
bool bModified = ! OutputEdges . IsEmpty ( ) ;
for ( FMetasoundFrontendEdge & OutputEdge : OutputEdges )
{
OutputEdge . FromNodeID = InputEdge . FromNodeID ;
OutputEdge . FromVertexID = InputEdge . FromVertexID ;
2024-06-27 18:32:11 -04:00
OutBuilder . AddEdge ( MoveTemp ( OutputEdge ) , & InPageID ) ;
2023-09-07 11:11:22 -04:00
}
2023-09-05 17:54:02 -04:00
2023-09-07 11:11:22 -04:00
return bModified ;
}
2023-09-05 17:54:02 -04:00
}
2023-09-06 12:54:02 -04:00
return false ;
2023-09-05 17:54:02 -04:00
}
2024-03-07 17:53:25 -05:00
2024-06-27 18:32:11 -04:00
const FMetasoundFrontendVertex * FindReroutedOutputVertex ( const FMetaSoundFrontendDocumentBuilder & InBuilder , const FGuid & InPageID , const FMetasoundFrontendNode & InOutputOwningNode , const FMetasoundFrontendVertex & InOutputVertex )
2024-03-07 17:53:25 -05:00
{
const FMetasoundFrontendVertex * ReroutedVertex = & InOutputVertex ;
if ( const FMetasoundFrontendClass * Class = InBuilder . FindDependency ( InOutputOwningNode . ClassID ) )
{
if ( Class - > Metadata . GetClassName ( ) = = FRerouteNodeTemplate : : ClassName )
{
const FGuid & OutputOwningNodeID = InOutputOwningNode . GetID ( ) ;
2024-06-27 18:32:11 -04:00
TArray < const FMetasoundFrontendVertex * > Inputs = InBuilder . FindNodeInputs ( OutputOwningNodeID , { } , & InPageID ) ;
2024-03-07 17:53:25 -05:00
if ( ! Inputs . IsEmpty ( ) )
{
if ( const FMetasoundFrontendVertex * RerouteInput = Inputs . Last ( ) )
{
const FMetasoundFrontendNode * ConnectedNode = nullptr ;
2024-06-27 18:32:11 -04:00
if ( const FMetasoundFrontendVertex * OutputVertex = InBuilder . FindNodeOutputConnectedToNodeInput ( OutputOwningNodeID , RerouteInput - > VertexID , & ConnectedNode , & InPageID ) )
2024-03-07 17:53:25 -05:00
{
check ( ConnectedNode ) ;
2024-06-27 18:32:11 -04:00
return FindReroutedOutputVertex ( InBuilder , InPageID , * ConnectedNode , * OutputVertex ) ;
2024-03-07 17:53:25 -05:00
}
}
}
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
return nullptr ;
2024-03-07 17:53:25 -05:00
}
}
return ReroutedVertex ;
}
void FindReroutedInputVertices (
const FMetaSoundFrontendDocumentBuilder & InBuilder ,
2024-06-27 18:32:11 -04:00
const FGuid & InPageID ,
2024-03-07 17:53:25 -05:00
const FMetasoundFrontendNode & InInputOwningNode ,
const FMetasoundFrontendVertex & InInputVertex ,
TArray < const FMetasoundFrontendNode * > & InOutReroutedInputOwningNodes ,
TArray < const FMetasoundFrontendVertex * > & InOutReroutedInputVertices )
{
using namespace Frontend ;
if ( const FMetasoundFrontendClass * Class = InBuilder . FindDependency ( InInputOwningNode . ClassID ) )
{
if ( Class - > Metadata . GetClassName ( ) = = FRerouteNodeTemplate : : ClassName )
{
const FGuid & InputOwningNodeID = InInputOwningNode . GetID ( ) ;
TArray < const FMetasoundFrontendVertex * > Outputs = InBuilder . FindNodeOutputs ( InputOwningNodeID ) ;
for ( const FMetasoundFrontendVertex * Output : Outputs )
{
check ( Output ) ;
TArray < const FMetasoundFrontendNode * > ConnectedInputNodes ;
2024-06-27 18:32:11 -04:00
TArray < const FMetasoundFrontendVertex * > ConnectedInputVertices = InBuilder . FindNodeInputsConnectedToNodeOutput ( InputOwningNodeID , Output - > VertexID , & ConnectedInputNodes , & InPageID ) ;
2024-03-07 17:53:25 -05:00
check ( ConnectedInputNodes . Num ( ) = = ConnectedInputVertices . Num ( ) ) ;
for ( int32 Index = 0 ; Index < ConnectedInputNodes . Num ( ) ; + + Index )
{
const FMetasoundFrontendNode * ConnectedInputOwningNode = ConnectedInputNodes [ Index ] ;
check ( ConnectedInputOwningNode ) ;
const FMetasoundFrontendVertex * ConnectedInputVertex = ConnectedInputVertices [ Index ] ;
check ( ConnectedInputVertex ) ;
2024-06-27 18:32:11 -04:00
FindReroutedInputVertices ( InBuilder , InPageID , * ConnectedInputOwningNode , * ConnectedInputVertex , InOutReroutedInputOwningNodes , InOutReroutedInputVertices ) ;
2024-03-07 17:53:25 -05:00
}
}
return ;
}
}
InOutReroutedInputOwningNodes . Add ( & InInputOwningNode ) ;
InOutReroutedInputVertices . Add ( & InInputVertex ) ;
}
2023-09-06 12:54:02 -04:00
} // namespace ReroutePrivate
2023-09-05 17:54:02 -04:00
const FMetasoundFrontendClassName FRerouteNodeTemplate : : ClassName { " UE " , " Reroute " , " " } ;
2023-10-12 16:37:45 -04:00
const FMetasoundFrontendVersionNumber FRerouteNodeTemplate : : VersionNumber { 1 , 0 } ;
const FMetasoundFrontendClassName & FRerouteNodeTemplate : : GetClassName ( ) const
{
2024-03-07 17:53:25 -05:00
return FRerouteNodeTemplate : : ClassName ;
2023-10-12 16:37:45 -04:00
}
2023-09-05 17:54:02 -04:00
2024-03-07 17:53:25 -05:00
# if WITH_EDITOR
2024-06-27 18:32:11 -04:00
FText FRerouteNodeTemplate : : GetNodeDisplayName ( const IMetaSoundDocumentInterface & DocumentInterface , const FGuid & InPageID , const FGuid & InNodeID ) const
2023-09-05 17:54:02 -04:00
{
2024-03-07 17:53:25 -05:00
return { } ;
}
# endif // WITH_EDITOR
FMetasoundFrontendNodeInterface FRerouteNodeTemplate : : GenerateNodeInterface ( FNodeTemplateGenerateInterfaceParams InParams ) const
{
FName DataType ;
if ( ! InParams . InputsToConnect . IsEmpty ( ) )
{
DataType = InParams . InputsToConnect . Last ( ) ;
}
if ( ! InParams . OutputsToConnect . IsEmpty ( ) )
{
const FName OutputDataType = InParams . OutputsToConnect . Last ( ) ;
if ( DataType . IsNone ( ) )
{
DataType = OutputDataType ;
}
else
{
checkf ( DataType = = OutputDataType , TEXT ( " Cannot generate MetasoundFrontendNodeInterface via reroute template with params of unmatched or unset input/output DataType " ) ) ;
}
}
static const FName VertexName = " Value " ;
FMetasoundFrontendNodeInterface NewInterface ;
NewInterface . Inputs . Add ( FMetasoundFrontendVertex { VertexName , DataType , FGuid : : NewGuid ( ) } ) ;
NewInterface . Outputs . Add ( FMetasoundFrontendVertex { VertexName , DataType , FGuid : : NewGuid ( ) } ) ;
return NewInterface ;
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
2023-09-05 17:54:02 -04:00
}
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
TUniquePtr < INodeTemplateTransform > FRerouteNodeTemplate : : GenerateNodeTransform ( ) const
2023-09-05 17:54:02 -04:00
{
using namespace ReroutePrivate ;
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
return TUniquePtr < INodeTemplateTransform > ( new FRerouteNodeTemplateTransform ( ) ) ;
2023-09-05 17:54:02 -04:00
}
const FMetasoundFrontendClass & FRerouteNodeTemplate : : GetFrontendClass ( ) const
{
auto CreateFrontendClass = [ ] ( )
{
FMetasoundFrontendClass Class ;
Class . Metadata . SetClassName ( ClassName ) ;
# if WITH_EDITOR
Class . Metadata . SetSerializeText ( false ) ;
Class . Metadata . SetAuthor ( Metasound : : PluginAuthor ) ;
Class . Metadata . SetDescription ( Metasound : : PluginNodeMissingPrompt ) ;
FMetasoundFrontendClassStyleDisplay & StyleDisplay = Class . Style . Display ;
StyleDisplay . ImageName = " MetasoundEditor.Graph.Node.Class.Reroute " ;
StyleDisplay . bShowInputNames = false ;
StyleDisplay . bShowOutputNames = false ;
StyleDisplay . bShowLiterals = false ;
StyleDisplay . bShowName = false ;
# endif // WITH_EDITOR
Class . Metadata . SetType ( EMetasoundFrontendClassType : : Template ) ;
2023-10-12 16:37:45 -04:00
Class . Metadata . SetVersion ( VersionNumber ) ;
2023-09-05 17:54:02 -04:00
return Class ;
} ;
static const FMetasoundFrontendClass FrontendClass = CreateFrontendClass ( ) ;
return FrontendClass ;
}
2024-08-13 14:58:36 -04:00
const TArray < FMetasoundFrontendClassInputDefault > * FRerouteNodeTemplate : : FindNodeClassInputDefaults ( const FMetaSoundFrontendDocumentBuilder & InBuilder , const FGuid & InPageID , const FGuid & InNodeID , FName VertexName ) const
{
// Recursive search up DAG for first connected non-reroute node's input class input
if ( const FMetasoundFrontendNode * Node = InBuilder . FindNode ( InNodeID , & InPageID ) )
{
// Should only ever be one
const FMetasoundFrontendVertex & RerouteOutput = Node - > Interface . Outputs . Last ( ) ;
TArray < const FMetasoundFrontendNode * > ConnectedNodes ;
TArray < const FMetasoundFrontendVertex * > ConnectedInputs = InBuilder . FindNodeInputsConnectedToNodeOutput ( InNodeID , RerouteOutput . VertexID , & ConnectedNodes , & InPageID ) ;
for ( int32 Index = 0 ; Index < ConnectedNodes . Num ( ) ; + + Index )
{
const FMetasoundFrontendNode * ConnectedNode = ConnectedNodes [ Index ] ;
if ( const FMetasoundFrontendClass * ConnectedNodeClass = InBuilder . FindDependency ( ConnectedNode - > ClassID ) )
{
const FMetasoundFrontendVertex * ConnectedInput = ConnectedInputs [ Index ] ;
if ( ConnectedNodeClass - > Metadata . GetClassName ( ) = = GetClassName ( ) )
{
return this - > FindNodeClassInputDefaults ( InBuilder , InPageID , ConnectedNode - > GetID ( ) , ConnectedInput - > Name ) ;
}
return InBuilder . FindNodeClassInputDefaults ( ConnectedNode - > GetID ( ) , ConnectedInput - > Name , & InPageID ) ;
}
}
}
return nullptr ;
}
2024-06-27 18:32:11 -04:00
EMetasoundFrontendVertexAccessType FRerouteNodeTemplate : : GetNodeInputAccessType ( const FMetaSoundFrontendDocumentBuilder & InBuilder , const FGuid & InPageID , const FGuid & InNodeID , const FGuid & InVertexID ) const
2023-09-07 11:11:22 -04:00
{
// Recursive search up DAG for first connected non-reroute node's input access type
2024-06-27 18:32:11 -04:00
if ( const FMetasoundFrontendNode * Node = InBuilder . FindNode ( InNodeID , & InPageID ) )
2023-09-07 11:11:22 -04:00
{
// Should only ever be one
const FMetasoundFrontendVertex & RerouteOutput = Node - > Interface . Outputs . Last ( ) ;
TArray < const FMetasoundFrontendNode * > ConnectedNodes ;
2024-06-27 18:32:11 -04:00
TArray < const FMetasoundFrontendVertex * > ConnectedInputs = InBuilder . FindNodeInputsConnectedToNodeOutput ( InNodeID , RerouteOutput . VertexID , & ConnectedNodes , & InPageID ) ;
2023-09-07 11:11:22 -04:00
for ( int32 Index = 0 ; Index < ConnectedNodes . Num ( ) ; + + Index )
{
const FMetasoundFrontendNode * ConnectedNode = ConnectedNodes [ Index ] ;
if ( const FMetasoundFrontendClass * ConnectedNodeClass = InBuilder . FindDependency ( ConnectedNode - > ClassID ) )
{
const FMetasoundFrontendVertex * ConnectedInput = ConnectedInputs [ Index ] ;
- Fix for attempting to access EngineSubsystem during MetaSound versioning (serialization), which can assert when apparently certain commands in certain contexts can attempt to preload assets prior to the init phase.
- Minor Fix for LocText duplication
#tests BuildCookRun, -game, version MetaSounds assets in editor, PIE
[FYI] bob.tellez
Original CL Desc
-----------------------------------------------------------------
[Backout] - CL33084850
[FYI] Rob.Gay
Original CL Desc
-----------------------------------------------------------------
Version Metasound Document to include all ed data and make all Metasound EdGraph data transient
- Add input template nodes
- Add comment node data to document
- Keep references to member literal data (i.e. knob/slider ranges) in document metadata to ensure continued serialization and flexibility to add more editor-only fields and literal metadata
- Misc builder API updates, bug fixes and migration of controllers to builder API in anticipation of pages
- Sunset non-deterministic guid cvar
#rb phil.popp, helen.yang
[FYI] sondra.moyls
#tests Standard Automated Audio Tests, EngineTests, Offline QA Smoke pass, CPR, etc., extensive MetaSound Editor use, -game MetaSound qa levels, AudioUnitTests
#jira UE-194159
[CL 33102023 by rob gay in ue5-main branch]
2024-04-19 10:09:04 -04:00
if ( ConnectedNodeClass - > Metadata . GetClassName ( ) = = GetClassName ( ) )
2023-09-07 11:11:22 -04:00
{
2024-06-27 18:32:11 -04:00
return this - > GetNodeInputAccessType ( InBuilder , InPageID , ConnectedNode - > GetID ( ) , ConnectedInput - > VertexID ) ;
2023-09-07 11:11:22 -04:00
}
2024-06-27 18:32:11 -04:00
return InBuilder . GetNodeInputAccessType ( ConnectedNode - > GetID ( ) , ConnectedInput - > VertexID , & InPageID ) ;
2023-09-07 11:11:22 -04:00
}
}
}
return EMetasoundFrontendVertexAccessType : : Unset ;
}
2024-06-27 18:32:11 -04:00
EMetasoundFrontendVertexAccessType FRerouteNodeTemplate : : GetNodeOutputAccessType ( const FMetaSoundFrontendDocumentBuilder & InBuilder , const FGuid & InPageID , const FGuid & InNodeID , const FGuid & InVertexID ) const
2023-09-07 11:11:22 -04:00
{
// Depth-first recursive search for first connected non-reroute node's output access type
if ( const FMetasoundFrontendNode * Node = InBuilder . FindNode ( InNodeID ) )
{
// Should only ever be one
const FMetasoundFrontendVertex & RerouteInput = Node - > Interface . Inputs . Last ( ) ;
const FMetasoundFrontendNode * ConnectedNode = nullptr ;
2024-06-27 18:32:11 -04:00
if ( const FMetasoundFrontendVertex * ConnectedOutput = InBuilder . FindNodeOutputConnectedToNodeInput ( InNodeID , RerouteInput . VertexID , & ConnectedNode , & InPageID ) )
2023-09-07 11:11:22 -04:00
{
if ( const FMetasoundFrontendClass * ConnectedNodeClass = InBuilder . FindDependency ( ConnectedNode - > ClassID ) )
{
if ( ConnectedNodeClass - > Metadata . GetClassName ( ) = = ClassName )
{
2024-06-27 18:32:11 -04:00
return this - > GetNodeOutputAccessType ( InBuilder , InPageID , ConnectedNode - > GetID ( ) , ConnectedOutput - > VertexID ) ;
2023-09-07 11:11:22 -04:00
}
2024-06-27 18:32:11 -04:00
return InBuilder . GetNodeOutputAccessType ( ConnectedNode - > GetID ( ) , ConnectedOutput - > VertexID , & InPageID ) ;
2023-09-07 11:11:22 -04:00
}
}
}
return EMetasoundFrontendVertexAccessType : : Unset ;
}
2023-09-05 17:54:02 -04:00
const FNodeRegistryKey & FRerouteNodeTemplate : : GetRegistryKey ( )
{
2023-10-12 16:37:45 -04:00
static const FNodeRegistryKey RegistryKey = FNodeRegistryKey ( EMetasoundFrontendClassType : : Template , ClassName , VersionNumber ) ;
2023-09-05 17:54:02 -04:00
return RegistryKey ;
}
2023-10-12 16:37:45 -04:00
const FMetasoundFrontendVersionNumber & FRerouteNodeTemplate : : GetVersionNumber ( ) const
2023-09-05 17:54:02 -04:00
{
2023-10-12 16:37:45 -04:00
return VersionNumber ;
2023-09-05 17:54:02 -04:00
}
# if WITH_EDITOR
2024-06-27 18:32:11 -04:00
bool FRerouteNodeTemplate : : HasRequiredConnections ( const FMetaSoundFrontendDocumentBuilder & InBuilder , const FGuid & InPageID , const FGuid & InNodeID , FString * OutMessage ) const
2023-09-05 17:54:02 -04:00
{
2024-03-07 17:53:25 -05:00
const FMetasoundFrontendNode * Node = InBuilder . FindNode ( InNodeID ) ;
if ( ! Node )
2023-09-05 17:54:02 -04:00
{
2024-03-07 17:53:25 -05:00
return false ;
}
2024-06-27 18:32:11 -04:00
TArray < const FMetasoundFrontendVertex * > Outputs = InBuilder . FindNodeOutputs ( InNodeID , { } , & InPageID ) ;
const bool bConnectedToNonRerouteOutputs = Algo : : AnyOf ( Outputs , [ & InBuilder , & InPageID , & Node ] ( const FMetasoundFrontendVertex * OutputVertex )
2024-03-07 17:53:25 -05:00
{
using namespace ReroutePrivate ;
2024-06-27 18:32:11 -04:00
return FindReroutedOutputVertex ( InBuilder , InPageID , * Node , * OutputVertex ) ! = nullptr ;
2024-03-07 17:53:25 -05:00
} ) ;
2024-06-27 18:32:11 -04:00
TArray < const FMetasoundFrontendVertex * > Inputs = InBuilder . FindNodeInputs ( InNodeID , { } , & InPageID ) ;
const bool bConnectedToNonRerouteInputs = Algo : : AnyOf ( Inputs , [ & InBuilder , & InPageID , & Node ] ( const FMetasoundFrontendVertex * InputVertex )
2024-03-07 17:53:25 -05:00
{
using namespace ReroutePrivate ;
TArray < const FMetasoundFrontendVertex * > InputVertices ;
TArray < const FMetasoundFrontendNode * > InputVerticesOwningNodes ;
2024-06-27 18:32:11 -04:00
FindReroutedInputVertices ( InBuilder , InPageID , * Node , * InputVertex , InputVerticesOwningNodes , InputVertices ) ;
2024-03-07 17:53:25 -05:00
return ! InputVertices . IsEmpty ( ) ;
2023-09-05 17:54:02 -04:00
} ) ;
2023-09-06 12:54:02 -04:00
const bool bHasRequiredConnections = bConnectedToNonRerouteOutputs | | bConnectedToNonRerouteOutputs = = bConnectedToNonRerouteInputs ;
if ( ! bHasRequiredConnections & & OutMessage )
{
* OutMessage = TEXT ( " Reroute node(s) missing non-reroute input connection(s). " ) ;
}
return bHasRequiredConnections ;
2023-09-05 17:54:02 -04:00
}
# endif // WITH_EDITOR
2023-09-07 11:11:22 -04:00
bool FRerouteNodeTemplate : : IsInputAccessTypeDynamic ( ) const
{
return true ;
}
2024-03-07 17:53:25 -05:00
bool FRerouteNodeTemplate : : IsInputConnectionUserModifiable ( ) const
{
return true ;
}
bool FRerouteNodeTemplate : : IsOutputConnectionUserModifiable ( ) const
{
return true ;
}
2023-09-07 11:11:22 -04:00
bool FRerouteNodeTemplate : : IsOutputAccessTypeDynamic ( ) const
{
return true ;
}
2023-09-05 17:54:02 -04:00
bool FRerouteNodeTemplate : : IsValidNodeInterface ( const FMetasoundFrontendNodeInterface & InNodeInterface ) const
{
if ( InNodeInterface . Inputs . Num ( ) ! = 1 )
{
return false ;
}
2022-08-12 14:22:05 -04:00
2023-09-05 17:54:02 -04:00
if ( InNodeInterface . Outputs . Num ( ) ! = 1 )
{
return false ;
2022-08-12 14:22:05 -04:00
}
2023-09-05 17:54:02 -04:00
const FName DataType = InNodeInterface . Inputs . Last ( ) . TypeName ;
if ( DataType ! = InNodeInterface . Outputs . Last ( ) . TypeName )
{
return false ;
}
return IDataTypeRegistry : : Get ( ) . IsRegistered ( DataType ) ;
}
} // namespace Metasound::Frontend