2020-09-24 00:43:27 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "RigVMModel/Nodes/RigVMSelectNode.h"
|
|
|
|
|
|
|
|
|
|
const FString URigVMSelectNode::SelectName = TEXT("Select");
|
|
|
|
|
const FString URigVMSelectNode::IndexName = TEXT("Index");
|
|
|
|
|
const FString URigVMSelectNode::ValueName = TEXT("Values");
|
|
|
|
|
const FString URigVMSelectNode::ResultName = TEXT("Result");
|
|
|
|
|
|
|
|
|
|
bool URigVMSelectNode::AllowsLinksOn(const URigVMPin* InPin) const
|
|
|
|
|
{
|
|
|
|
|
if(InPin->GetRootPin() == InPin)
|
|
|
|
|
{
|
|
|
|
|
if(InPin->GetName() == ValueName)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2022-04-21 09:10:19 -04:00
|
|
|
|
|
|
|
|
FName URigVMSelectNode::GetNotation() const
|
|
|
|
|
{
|
|
|
|
|
static constexpr TCHAR Format[] = TEXT("%s(in %s, in %s, out %s)");
|
|
|
|
|
static const FName Notation = *FString::Printf(Format, *SelectName, *IndexName, *ValueName, *ResultName);
|
|
|
|
|
return Notation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FRigVMTemplate* URigVMSelectNode::GetTemplate() const
|
|
|
|
|
{
|
|
|
|
|
if(const FRigVMTemplate* SuperTemplate = Super::GetTemplate())
|
|
|
|
|
{
|
|
|
|
|
return SuperTemplate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(CachedTemplate == nullptr)
|
|
|
|
|
{
|
2022-06-07 11:01:59 -04:00
|
|
|
const TArray<FRigVMTemplateArgumentType>& SingleTypes = FRigVMTemplateArgument::GetCompatibleTypes(FRigVMTemplateArgument::ETypeCategory_SingleAnyValue);
|
|
|
|
|
const TArray<FRigVMTemplateArgumentType>& ArrayTypes = FRigVMTemplateArgument::GetCompatibleTypes(FRigVMTemplateArgument::ETypeCategory_ArrayAnyValue);
|
|
|
|
|
const TArray<FRigVMTemplateArgumentType>& ArrayArrayTypes = FRigVMTemplateArgument::GetCompatibleTypes(FRigVMTemplateArgument::ETypeCategory_ArrayArrayAnyValue);
|
2022-05-20 11:00:38 -04:00
|
|
|
|
2022-06-07 11:01:59 -04:00
|
|
|
TArray<FRigVMTemplateArgumentType> ResultTypes = SingleTypes;
|
2022-05-20 11:00:38 -04:00
|
|
|
ResultTypes.Append(ArrayTypes);
|
2022-06-07 11:01:59 -04:00
|
|
|
TArray<FRigVMTemplateArgumentType> ValueTypes = ArrayTypes;
|
2022-05-20 11:00:38 -04:00
|
|
|
ValueTypes.Append(ArrayArrayTypes);
|
2022-04-21 09:10:19 -04:00
|
|
|
|
|
|
|
|
TArray<FRigVMTemplateArgument> Arguments;
|
2022-06-07 11:01:59 -04:00
|
|
|
Arguments.Emplace(*IndexName, ERigVMPinDirection::Input, FRigVMTemplateArgumentType(RigVMTypeUtils::Int32Type, nullptr));
|
2022-05-20 11:00:38 -04:00
|
|
|
Arguments.Emplace(*ValueName, ERigVMPinDirection::Input, ValueTypes);
|
|
|
|
|
Arguments.Emplace(*ResultName, ERigVMPinDirection::Output, ResultTypes);
|
2022-04-21 09:10:19 -04:00
|
|
|
|
|
|
|
|
CachedTemplate = FRigVMRegistry::Get().GetOrAddTemplateFromArguments(*SelectName, Arguments);
|
|
|
|
|
}
|
|
|
|
|
return CachedTemplate;
|
|
|
|
|
}
|