Files
UnrealEngineUWP/Engine/Plugins/Animation/ControlRig/Source/ControlRigDeveloper/Public/Graph/ControlRigGraph.h
helge mathee c98e25e225 RigVM: First steps towards rebasing ControlRigBlueprint
#rb sara.schvartzman
#jira UE-180106

[CL 26016011 by helge mathee in ue5-main branch]
2023-06-15 11:30:29 -04:00

150 lines
4.5 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "ControlRigBlueprint.h"
#include "EdGraph/EdGraph.h"
#include "Graph/ControlRigGraphNode.h"
#include "Rigs/RigHierarchy.h"
#include "Rigs/RigHierarchyController.h"
#include "RigVMModel/RigVMGraph.h"
#include "RigVMCore/RigVM.h"
#include "EdGraph/RigVMEdGraph.h"
#include "ControlRigGraph.generated.h"
class UControlRigBlueprint;
class UControlRigGraphSchema;
class UControlRig;
class URigVMController;
struct FRigCurveContainer;
UCLASS()
class CONTROLRIGDEVELOPER_API UControlRigGraph : public URigVMEdGraph
{
GENERATED_BODY()
public:
UControlRigGraph();
/** Set up this graph */
virtual void InitializeFromBlueprint(URigVMBlueprint* InBlueprint) override;
virtual bool HandleModifiedEvent_Internal(ERigVMGraphNotifType InNotifType, URigVMGraph* InGraph, UObject* InSubject) override;
#if WITH_EDITOR
const TArray<TSharedPtr<FString>>* GetBoneNameList(URigVMPin* InPin = nullptr) const
{
return GetElementNameList(ERigElementType::Bone);
}
const TArray<TSharedPtr<FString>>* GetControlNameList(URigVMPin* InPin = nullptr) const
{
return GetElementNameList(ERigElementType::Control);
}
const TArray<TSharedPtr<FString>>* GetControlNameListWithoutAnimationChannels(URigVMPin* InPin = nullptr) const
{
return &ControlNameListWithoutAnimationChannels;
}
const TArray<TSharedPtr<FString>>* GetNullNameList(URigVMPin* InPin = nullptr) const
{
return GetElementNameList(ERigElementType::Null);
}
const TArray<TSharedPtr<FString>>* GetCurveNameList(URigVMPin* InPin = nullptr) const
{
return GetElementNameList(ERigElementType::Curve);
}
void CacheNameLists(URigHierarchy* InHierarchy, const FRigVMDrawContainer* DrawContainer, TArray<TSoftObjectPtr<UControlRigShapeLibrary>> ShapeLibraries);
const TArray<TSharedPtr<FString>>* GetElementNameList(ERigElementType InElementType = ERigElementType::Bone) const;
const TArray<TSharedPtr<FString>>* GetElementNameList(URigVMPin* InPin = nullptr) const;
const TArray<TSharedPtr<FString>> GetSelectedElementsNameList() const;
const TArray<TSharedPtr<FString>>* GetDrawingNameList(URigVMPin* InPin = nullptr) const;
const TArray<TSharedPtr<FString>>* GetEntryNameList(URigVMPin* InPin = nullptr) const;
const TArray<TSharedPtr<FString>>* GetShapeNameList(URigVMPin* InPin = nullptr) const;
private:
template<class T>
static bool IncludeElementInNameList(const T* InElement)
{
return true;
}
template<class T>
void CacheNameListForHierarchy(URigHierarchy* InHierarchy, TArray<TSharedPtr<FString>>& OutNameList, bool bFilter = true)
{
TArray<FString> Names;
for (auto Element : *InHierarchy)
{
if(Element->IsA<T>())
{
if(!bFilter || IncludeElementInNameList<T>(Cast<T>(Element)))
{
Names.Add(Element->GetName().ToString());
}
}
}
Names.Sort();
OutNameList.Reset();
OutNameList.Add(MakeShared<FString>(FName(NAME_None).ToString()));
for (const FString& Name : Names)
{
OutNameList.Add(MakeShared<FString>(Name));
}
}
template<class T>
void CacheNameList(const T& ElementList, TArray<TSharedPtr<FString>>& OutNameList)
{
TArray<FString> Names;
for (auto Element : ElementList)
{
Names.Add(Element.Name.ToString());
}
Names.Sort();
OutNameList.Reset();
OutNameList.Add(MakeShared<FString>(FName(NAME_None).ToString()));
for (const FString& Name : Names)
{
OutNameList.Add(MakeShared<FString>(Name));
}
}
TMap<ERigElementType, TArray<TSharedPtr<FString>>> ElementNameLists;
TArray<TSharedPtr<FString>> ControlNameListWithoutAnimationChannels;
TArray<TSharedPtr<FString>> DrawingNameList;
TArray<TSharedPtr<FString>> EntryNameList;
TArray<TSharedPtr<FString>> ShapeNameList;
int32 LastHierarchyTopologyVersion;
static TArray<TSharedPtr<FString>> EmptyElementNameList;
#endif
friend class UControlRigUnitNodeSpawner;
friend class UControlRigVariableNodeSpawner;
friend class UControlRigParameterNodeSpawner;
friend class UControlRigBranchNodeSpawner;
friend class UControlRigIfNodeSpawner;
friend class UControlRigSelectNodeSpawner;
friend class UControlRigTemplateNodeSpawner;
friend class UControlRigEnumNodeSpawner;
friend class UControlRigFunctionRefNodeSpawner;
friend class UControlRigArrayNodeSpawner;
friend class UControlRigInvokeEntryNodeSpawner;
friend class UControlRigGraphNode;
friend class FControlRigEditor;
friend class SControlRigGraphNode;
friend class UControlRigBlueprint;
};
template<>
inline bool UControlRigGraph::IncludeElementInNameList<FRigControlElement>(const FRigControlElement* InElement)
{
return !InElement->IsAnimationChannel();
}