2019-12-27 09:26:59 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2018-04-12 16:57:51 -04:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2021-03-03 14:44:58 -04:00
|
|
|
#include "ControlRigBlueprint.h"
|
2018-04-12 16:57:51 -04:00
|
|
|
#include "EdGraph/EdGraph.h"
|
2019-04-02 11:26:55 -04:00
|
|
|
#include "Graph/ControlRigGraphNode.h"
|
2021-02-22 13:36:33 -04:00
|
|
|
#include "Rigs/RigHierarchy.h"
|
|
|
|
|
#include "Rigs/RigHierarchyController.h"
|
2020-01-22 17:58:55 -05:00
|
|
|
#include "RigVMModel/RigVMGraph.h"
|
2021-01-26 04:06:19 -04:00
|
|
|
#include "RigVMCore/RigVM.h"
|
2020-01-22 17:58:55 -05:00
|
|
|
#include "Drawing/ControlRigDrawContainer.h"
|
2018-04-12 16:57:51 -04:00
|
|
|
#include "ControlRigGraph.generated.h"
|
|
|
|
|
|
|
|
|
|
class UControlRigBlueprint;
|
|
|
|
|
class UControlRigGraphSchema;
|
2019-04-02 11:26:55 -04:00
|
|
|
class UControlRig;
|
2020-01-22 17:58:55 -05:00
|
|
|
class URigVMController;
|
2019-07-16 11:49:59 -04:00
|
|
|
struct FRigCurveContainer;
|
2018-04-12 16:57:51 -04:00
|
|
|
|
2020-02-04 11:06:23 -05:00
|
|
|
DECLARE_MULTICAST_DELEGATE_OneParam(FControlRigGraphNodeClicked, UControlRigGraphNode*);
|
|
|
|
|
|
2018-04-12 16:57:51 -04:00
|
|
|
UCLASS()
|
2022-05-31 04:27:20 -04:00
|
|
|
class CONTROLRIGDEVELOPER_API UControlRigGraph : public UEdGraph, public IRigVMEditorSideObject
|
2018-04-12 16:57:51 -04:00
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
UControlRigGraph();
|
|
|
|
|
|
2022-05-31 04:27:20 -04:00
|
|
|
/** IRigVMEditorSideObject interface */
|
|
|
|
|
virtual FRigVMClient* GetRigVMClient() const override;
|
|
|
|
|
virtual FString GetRigVMNodePath() const override;
|
|
|
|
|
virtual void HandleRigVMGraphRenamed(const FString& InOldNodePath, const FString& InNewNodePath) override;
|
|
|
|
|
|
2018-04-12 16:57:51 -04:00
|
|
|
/** Set up this graph */
|
|
|
|
|
void Initialize(UControlRigBlueprint* InBlueprint);
|
|
|
|
|
|
|
|
|
|
/** Get the skeleton graph schema */
|
|
|
|
|
const UControlRigGraphSchema* GetControlRigGraphSchema();
|
2019-04-02 11:26:55 -04:00
|
|
|
|
|
|
|
|
#if WITH_EDITORONLY_DATA
|
|
|
|
|
/** Customize blueprint changes based on backwards compatibility */
|
|
|
|
|
virtual void Serialize(FArchive& Ar) override;
|
|
|
|
|
#endif
|
|
|
|
|
#if WITH_EDITOR
|
2019-05-21 19:25:23 -04:00
|
|
|
|
2021-05-06 14:21:04 -04:00
|
|
|
FORCEINLINE const TArray<TSharedPtr<FString>>* GetBoneNameList(URigVMPin* InPin = nullptr) const
|
2021-02-23 12:51:49 -04:00
|
|
|
{
|
|
|
|
|
return GetElementNameList(ERigElementType::Bone);
|
|
|
|
|
}
|
2021-05-06 14:21:04 -04:00
|
|
|
FORCEINLINE const TArray<TSharedPtr<FString>>* GetControlNameList(URigVMPin* InPin = nullptr) const
|
2021-02-23 12:51:49 -04:00
|
|
|
{
|
|
|
|
|
return GetElementNameList(ERigElementType::Control);
|
|
|
|
|
}
|
2021-05-06 14:21:04 -04:00
|
|
|
FORCEINLINE const TArray<TSharedPtr<FString>>* GetNullNameList(URigVMPin* InPin = nullptr) const
|
2021-02-23 12:51:49 -04:00
|
|
|
{
|
2021-03-05 04:30:31 -04:00
|
|
|
return GetElementNameList(ERigElementType::Null);
|
2021-02-23 12:51:49 -04:00
|
|
|
}
|
2021-05-06 14:21:04 -04:00
|
|
|
FORCEINLINE const TArray<TSharedPtr<FString>>* GetCurveNameList(URigVMPin* InPin = nullptr) const
|
2021-02-23 12:51:49 -04:00
|
|
|
{
|
|
|
|
|
return GetElementNameList(ERigElementType::Curve);
|
|
|
|
|
}
|
2021-02-24 06:22:36 -04:00
|
|
|
|
|
|
|
|
void CacheNameLists(URigHierarchy* InHierarchy, const FControlRigDrawContainer* DrawContainer);
|
2021-05-06 14:21:04 -04:00
|
|
|
const TArray<TSharedPtr<FString>>* GetElementNameList(ERigElementType InElementType = ERigElementType::Bone) const;
|
|
|
|
|
const TArray<TSharedPtr<FString>>* GetElementNameList(URigVMPin* InPin = nullptr) const;
|
2021-05-25 05:36:45 -04:00
|
|
|
const TArray<TSharedPtr<FString>> GetSelectedElementsNameList() const;
|
2021-05-06 14:21:04 -04:00
|
|
|
const TArray<TSharedPtr<FString>>* GetDrawingNameList(URigVMPin* InPin = nullptr) const;
|
2019-04-02 11:26:55 -04:00
|
|
|
|
2019-05-21 19:25:23 -04:00
|
|
|
bool bSuspendModelNotifications;
|
|
|
|
|
bool bIsTemporaryGraphForCopyPaste;
|
|
|
|
|
|
2021-06-15 12:47:10 -04:00
|
|
|
UEdGraphNode* FindNodeForModelNodeName(const FName& InModelNodeName, const bool bCacheIfRequired = true);
|
2019-05-21 19:25:23 -04:00
|
|
|
|
2020-12-07 07:55:48 -04:00
|
|
|
UControlRigBlueprint* GetBlueprint() const;
|
2022-05-31 04:27:20 -04:00
|
|
|
URigVMGraph* GetModel() const;
|
|
|
|
|
URigVMController* GetController() const;
|
|
|
|
|
bool IsRootGraph() const { return GetRootGraph() == this; }
|
|
|
|
|
const UControlRigGraph* GetRootGraph() const;
|
2020-12-07 07:55:48 -04:00
|
|
|
|
2020-01-22 17:58:55 -05:00
|
|
|
void HandleModifiedEvent(ERigVMGraphNotifType InNotifType, URigVMGraph* InGraph, UObject* InSubject);
|
2019-05-21 19:25:23 -04:00
|
|
|
|
2021-08-24 16:56:09 -04:00
|
|
|
int32 GetInstructionIndex(const UControlRigGraphNode* InNode, bool bAsInput);
|
2021-01-26 04:06:19 -04:00
|
|
|
|
2020-12-14 08:58:12 -04:00
|
|
|
UPROPERTY()
|
|
|
|
|
FString ModelNodePath;
|
|
|
|
|
|
2021-01-14 15:00:40 -04:00
|
|
|
UPROPERTY()
|
|
|
|
|
bool bIsFunctionDefinition;
|
|
|
|
|
|
2021-03-03 14:44:58 -04:00
|
|
|
FControlRigPublicFunctionData GetPublicFunctionData() const;
|
|
|
|
|
|
2020-12-14 08:58:12 -04:00
|
|
|
private:
|
|
|
|
|
|
2021-02-22 13:36:33 -04:00
|
|
|
template<class T>
|
|
|
|
|
void CacheNameListForHierarchy(URigHierarchy* InHierarchy, TArray<TSharedPtr<FString>>& OutNameList)
|
|
|
|
|
{
|
|
|
|
|
TArray<FString> Names;
|
|
|
|
|
for (auto Element : *InHierarchy)
|
|
|
|
|
{
|
|
|
|
|
if(Element->IsA<T>())
|
|
|
|
|
{
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-17 19:12:19 -04:00
|
|
|
template<class T>
|
2020-01-22 17:58:55 -05:00
|
|
|
void CacheNameList(const T& ElementList, TArray<TSharedPtr<FString>>& OutNameList)
|
2019-09-17 19:12:19 -04:00
|
|
|
{
|
|
|
|
|
TArray<FString> Names;
|
2020-01-22 17:58:55 -05:00
|
|
|
for (auto Element : ElementList)
|
2019-09-17 19:12:19 -04:00
|
|
|
{
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-23 12:51:49 -04:00
|
|
|
TMap<ERigElementType, TArray<TSharedPtr<FString>>> ElementNameLists;
|
2020-01-22 17:58:55 -05:00
|
|
|
TArray<TSharedPtr<FString>> DrawingNameList;
|
2021-05-06 09:44:01 -04:00
|
|
|
int32 LastHierarchyTopologyVersion;
|
2020-01-22 17:58:55 -05:00
|
|
|
|
|
|
|
|
bool bIsSelecting;
|
|
|
|
|
|
2020-02-04 11:06:23 -05:00
|
|
|
FControlRigGraphNodeClicked OnGraphNodeClicked;
|
|
|
|
|
|
2021-08-24 16:56:09 -04:00
|
|
|
TMap<URigVMNode*, TPair<int32, int32>> CachedInstructionIndices;
|
2021-01-26 04:06:19 -04:00
|
|
|
|
2022-05-20 04:43:05 -04:00
|
|
|
void RemoveNode(UEdGraphNode* InNode);
|
2022-03-01 04:23:55 -05:00
|
|
|
|
2019-04-02 11:26:55 -04:00
|
|
|
#endif
|
2020-01-22 17:58:55 -05:00
|
|
|
#if WITH_EDITORONLY_DATA
|
|
|
|
|
|
|
|
|
|
UPROPERTY(transient)
|
2021-07-20 00:21:34 -04:00
|
|
|
TObjectPtr<URigVMController> TemplateController;
|
2020-01-22 17:58:55 -05:00
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
#if WITH_EDITOR
|
|
|
|
|
|
|
|
|
|
URigVMController* GetTemplateController();
|
|
|
|
|
|
2022-04-06 08:26:45 -04:00
|
|
|
protected:
|
|
|
|
|
void HandleVMCompiledEvent(UObject* InCompiledObject, URigVM* InVM);
|
|
|
|
|
|
|
|
|
|
private:
|
2021-02-24 06:22:36 -04:00
|
|
|
static TArray<TSharedPtr<FString>> EmptyElementNameList;
|
2021-06-03 04:42:39 -04:00
|
|
|
TMap<FName, UEdGraphNode*> ModelNodePathToEdNode;
|
2021-02-24 06:22:36 -04:00
|
|
|
|
2020-01-22 17:58:55 -05:00
|
|
|
friend class UControlRigUnitNodeSpawner;
|
|
|
|
|
friend class UControlRigVariableNodeSpawner;
|
|
|
|
|
friend class UControlRigParameterNodeSpawner;
|
|
|
|
|
friend class UControlRigRerouteNodeSpawner;
|
2020-09-24 00:43:27 -04:00
|
|
|
friend class UControlRigBranchNodeSpawner;
|
|
|
|
|
friend class UControlRigIfNodeSpawner;
|
|
|
|
|
friend class UControlRigSelectNodeSpawner;
|
2022-03-01 04:23:55 -05:00
|
|
|
friend class UControlRigTemplateNodeSpawner;
|
2020-09-24 00:43:27 -04:00
|
|
|
friend class UControlRigEnumNodeSpawner;
|
2021-01-18 08:22:35 -04:00
|
|
|
friend class UControlRigFunctionRefNodeSpawner;
|
2021-08-18 06:18:05 -04:00
|
|
|
friend class UControlRigArrayNodeSpawner;
|
2021-01-26 04:06:19 -04:00
|
|
|
|
2020-01-22 17:58:55 -05:00
|
|
|
#endif
|
|
|
|
|
friend class UControlRigGraphNode;
|
|
|
|
|
friend class FControlRigEditor;
|
2020-02-04 11:06:23 -05:00
|
|
|
friend class SControlRigGraphNode;
|
2021-01-26 04:06:19 -04:00
|
|
|
friend class UControlRigBlueprint;
|
2018-04-12 16:57:51 -04:00
|
|
|
};
|
|
|
|
|
|