// 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 "Drawing/ControlRigDrawContainer.h" #include "ControlRigGraph.generated.h" class UControlRigBlueprint; class UControlRigGraphSchema; class UControlRig; class URigVMController; struct FRigCurveContainer; DECLARE_MULTICAST_DELEGATE_OneParam(FControlRigGraphNodeClicked, UControlRigGraphNode*); UCLASS() class CONTROLRIGDEVELOPER_API UControlRigGraph : public UEdGraph { GENERATED_BODY() public: UControlRigGraph(); /** Set up this graph */ void Initialize(UControlRigBlueprint* InBlueprint); /** Get the skeleton graph schema */ const UControlRigGraphSchema* GetControlRigGraphSchema(); #if WITH_EDITORONLY_DATA /** Customize blueprint changes based on backwards compatibility */ virtual void Serialize(FArchive& Ar) override; #endif #if WITH_EDITOR FORCEINLINE const TArray>* GetBoneNameList(URigVMPin* InPin = nullptr) const { return GetElementNameList(ERigElementType::Bone); } FORCEINLINE const TArray>* GetControlNameList(URigVMPin* InPin = nullptr) const { return GetElementNameList(ERigElementType::Control); } FORCEINLINE const TArray>* GetNullNameList(URigVMPin* InPin = nullptr) const { return GetElementNameList(ERigElementType::Null); } FORCEINLINE const TArray>* GetCurveNameList(URigVMPin* InPin = nullptr) const { return GetElementNameList(ERigElementType::Curve); } void CacheNameLists(URigHierarchy* InHierarchy, const FControlRigDrawContainer* DrawContainer); const TArray>* GetElementNameList(ERigElementType InElementType = ERigElementType::Bone) const; const TArray>* GetElementNameList(URigVMPin* InPin = nullptr) const; const TArray> GetSelectedElementsNameList() const; const TArray>* GetDrawingNameList(URigVMPin* InPin = nullptr) const; bool bSuspendModelNotifications; bool bIsTemporaryGraphForCopyPaste; UEdGraphNode* FindNodeForModelNodeName(const FName& InModelNodeName, const bool bCacheIfRequired = true); UControlRigBlueprint* GetBlueprint() const; URigVMGraph* GetModel() const; URigVMController* GetController() const; void HandleModifiedEvent(ERigVMGraphNotifType InNotifType, URigVMGraph* InGraph, UObject* InSubject); int32 GetInstructionIndex(UControlRigGraphNode* InNode); UPROPERTY() FString ModelNodePath; UPROPERTY() bool bIsFunctionDefinition; FControlRigPublicFunctionData GetPublicFunctionData() const; private: template void CacheNameListForHierarchy(URigHierarchy* InHierarchy, TArray>& OutNameList) { TArray Names; for (auto Element : *InHierarchy) { if(Element->IsA()) { Names.Add(Element->GetName().ToString()); } } Names.Sort(); OutNameList.Reset(); OutNameList.Add(MakeShared(FName(NAME_None).ToString())); for (const FString& Name : Names) { OutNameList.Add(MakeShared(Name)); } } template void CacheNameList(const T& ElementList, TArray>& OutNameList) { TArray Names; for (auto Element : ElementList) { Names.Add(Element.Name.ToString()); } Names.Sort(); OutNameList.Reset(); OutNameList.Add(MakeShared(FName(NAME_None).ToString())); for (const FString& Name : Names) { OutNameList.Add(MakeShared(Name)); } } TMap>> ElementNameLists; TArray> DrawingNameList; int32 LastHierarchyTopologyVersion; bool bIsSelecting; FControlRigGraphNodeClicked OnGraphNodeClicked; TMap CachedInstructionIndices; #endif #if WITH_EDITORONLY_DATA UPROPERTY(transient) URigVMController* TemplateController; #endif #if WITH_EDITOR URigVMController* GetTemplateController(); void HandleVMCompiledEvent(UBlueprint* InBlueprint, URigVM* InVM); static TArray> EmptyElementNameList; TMap ModelNodePathToEdNode; friend class UControlRigUnitNodeSpawner; friend class UControlRigVariableNodeSpawner; friend class UControlRigParameterNodeSpawner; friend class UControlRigRerouteNodeSpawner; friend class UControlRigBranchNodeSpawner; friend class UControlRigIfNodeSpawner; friend class UControlRigSelectNodeSpawner; friend class UControlRigPrototypeNodeSpawner; friend class UControlRigEnumNodeSpawner; friend class UControlRigFunctionRefNodeSpawner; #endif friend class UControlRigGraphNode; friend class FControlRigEditor; friend class SControlRigGraphNode; friend class UControlRigBlueprint; };