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"
|
2023-06-15 11:30:29 -04:00
|
|
|
#include "EdGraph/RigVMEdGraph.h"
|
2018-04-12 16:57:51 -04:00
|
|
|
#include "ControlRigGraph.generated.h"
|
|
|
|
|
|
|
|
|
|
class UControlRigBlueprint;
|
|
|
|
|
class UControlRigGraphSchema;
|
2023-10-30 07:01:53 -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
|
|
|
|
|
|
|
|
UCLASS()
|
2023-06-15 11:30:29 -04:00
|
|
|
class CONTROLRIGDEVELOPER_API UControlRigGraph : public URigVMEdGraph
|
2018-04-12 16:57:51 -04:00
|
|
|
{
|
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
UControlRigGraph();
|
|
|
|
|
|
|
|
|
|
/** Set up this graph */
|
2023-06-15 11:30:29 -04:00
|
|
|
virtual void InitializeFromBlueprint(URigVMBlueprint* InBlueprint) override;
|
2018-04-12 16:57:51 -04:00
|
|
|
|
2023-06-15 11:30:29 -04:00
|
|
|
virtual bool HandleModifiedEvent_Internal(ERigVMGraphNotifType InNotifType, URigVMGraph* InGraph, UObject* InSubject) override;
|
2019-04-02 11:26:55 -04:00
|
|
|
|
|
|
|
|
#if WITH_EDITOR
|
2019-05-21 19:25:23 -04:00
|
|
|
|
2023-09-28 09:19:30 -04:00
|
|
|
const TArray<TSharedPtr<FRigVMStringWithTag>>* GetBoneNameList(URigVMPin* InPin = nullptr) const
|
2021-02-23 12:51:49 -04:00
|
|
|
{
|
|
|
|
|
return GetElementNameList(ERigElementType::Bone);
|
|
|
|
|
}
|
2023-09-28 09:19:30 -04:00
|
|
|
const TArray<TSharedPtr<FRigVMStringWithTag>>* GetControlNameList(URigVMPin* InPin = nullptr) const
|
2021-02-23 12:51:49 -04:00
|
|
|
{
|
|
|
|
|
return GetElementNameList(ERigElementType::Control);
|
|
|
|
|
}
|
2023-09-28 09:19:30 -04:00
|
|
|
const TArray<TSharedPtr<FRigVMStringWithTag>>* GetControlNameListWithoutAnimationChannels(URigVMPin* InPin = nullptr) const
|
2022-07-07 10:33:32 -04:00
|
|
|
{
|
|
|
|
|
return &ControlNameListWithoutAnimationChannels;
|
|
|
|
|
}
|
2023-09-28 09:19:30 -04:00
|
|
|
const TArray<TSharedPtr<FRigVMStringWithTag>>* 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
|
|
|
}
|
2023-09-28 09:19:30 -04:00
|
|
|
const TArray<TSharedPtr<FRigVMStringWithTag>>* GetCurveNameList(URigVMPin* InPin = nullptr) const
|
2021-02-23 12:51:49 -04:00
|
|
|
{
|
|
|
|
|
return GetElementNameList(ERigElementType::Curve);
|
|
|
|
|
}
|
2023-09-28 09:19:30 -04:00
|
|
|
const TArray<TSharedPtr<FRigVMStringWithTag>>* GetConnectorNameList(URigVMPin* InPin = nullptr) const
|
2023-08-09 07:54:54 -04:00
|
|
|
{
|
|
|
|
|
return GetElementNameList(ERigElementType::Connector);
|
|
|
|
|
}
|
2023-10-17 09:02:48 -04:00
|
|
|
const TArray<TSharedPtr<FRigVMStringWithTag>>* GetSocketNameList(URigVMPin* InPin = nullptr) const
|
|
|
|
|
{
|
|
|
|
|
return GetElementNameList(ERigElementType::Socket);
|
|
|
|
|
}
|
2021-02-24 06:22:36 -04:00
|
|
|
|
2023-09-28 09:19:30 -04:00
|
|
|
virtual const TArray<TSharedPtr<FRigVMStringWithTag>>* GetNameListForWidget(const FString& InWidgetName) const override;
|
2023-06-23 10:03:02 -04:00
|
|
|
|
2022-12-06 11:04:15 -05:00
|
|
|
void CacheNameLists(URigHierarchy* InHierarchy, const FRigVMDrawContainer* DrawContainer, TArray<TSoftObjectPtr<UControlRigShapeLibrary>> ShapeLibraries);
|
2023-09-28 09:19:30 -04:00
|
|
|
const TArray<TSharedPtr<FRigVMStringWithTag>>* GetElementNameList(ERigElementType InElementType = ERigElementType::Bone) const;
|
|
|
|
|
const TArray<TSharedPtr<FRigVMStringWithTag>>* GetElementNameList(URigVMPin* InPin = nullptr) const;
|
|
|
|
|
const TArray<TSharedPtr<FRigVMStringWithTag>> GetSelectedElementsNameList() const;
|
|
|
|
|
const TArray<TSharedPtr<FRigVMStringWithTag>>* GetDrawingNameList(URigVMPin* InPin = nullptr) const;
|
|
|
|
|
const TArray<TSharedPtr<FRigVMStringWithTag>>* GetShapeNameList(URigVMPin* InPin = nullptr) const;
|
2019-04-02 11:26:55 -04:00
|
|
|
|
2023-06-21 05:47:17 -04:00
|
|
|
FReply HandleGetSelectedClicked(URigVMEdGraph* InEdGraph, URigVMPin* InPin, FString InDefaultValue);
|
|
|
|
|
FReply HandleBrowseClicked(URigVMEdGraph* InEdGraph, URigVMPin* InPin, FString InDefaultValue);
|
2023-06-13 03:49:40 -04:00
|
|
|
|
2020-12-14 08:58:12 -04:00
|
|
|
private:
|
|
|
|
|
|
2022-06-10 09:35:29 -04:00
|
|
|
template<class T>
|
|
|
|
|
static bool IncludeElementInNameList(const T* InElement)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-22 13:36:33 -04:00
|
|
|
template<class T>
|
2023-10-30 07:01:53 -04:00
|
|
|
void CacheNameListForHierarchy(UControlRig* InControlRig, URigHierarchy* InHierarchy, TArray<TSharedPtr<FRigVMStringWithTag>>& OutNameList, bool bFilter = true)
|
2021-02-22 13:36:33 -04:00
|
|
|
{
|
2023-09-28 09:19:30 -04:00
|
|
|
TArray<FRigVMStringWithTag> Names;
|
2021-02-22 13:36:33 -04:00
|
|
|
for (auto Element : *InHierarchy)
|
|
|
|
|
{
|
|
|
|
|
if(Element->IsA<T>())
|
|
|
|
|
{
|
2022-07-07 10:33:32 -04:00
|
|
|
if(!bFilter || IncludeElementInNameList<T>(Cast<T>(Element)))
|
2022-06-10 09:35:29 -04:00
|
|
|
{
|
2023-09-28 09:19:30 -04:00
|
|
|
static const FLinearColor Color(FLinearColor(0.0, 112.f/255.f, 224.f/255.f));
|
|
|
|
|
FRigVMStringTag Tag;
|
|
|
|
|
|
2023-09-21 08:46:06 -04:00
|
|
|
if(InControlRig)
|
|
|
|
|
{
|
|
|
|
|
if(const FRigElementKey* SourceKey = InControlRig->GetElementKeyRedirector().FindReverse(Element->GetKey()))
|
|
|
|
|
{
|
2023-09-28 09:19:30 -04:00
|
|
|
Tag = FRigVMStringTag(Element->GetKey().Name, Color);
|
|
|
|
|
Names.Emplace(SourceKey->Name.ToString(), Tag);
|
2023-09-21 08:46:06 -04:00
|
|
|
continue;
|
|
|
|
|
}
|
2023-09-28 09:19:30 -04:00
|
|
|
|
|
|
|
|
// look up the resolved name
|
|
|
|
|
if(Element->GetType() == ERigElementType::Connector)
|
|
|
|
|
{
|
|
|
|
|
if(const FCachedRigElement* Cache = InControlRig->GetElementKeyRedirector().Find(Element->GetKey()))
|
|
|
|
|
{
|
|
|
|
|
Tag = FRigVMStringTag(Cache->GetKey().Name, Color);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-21 08:46:06 -04:00
|
|
|
}
|
2023-09-28 09:19:30 -04:00
|
|
|
|
|
|
|
|
Names.Emplace(Element->GetName(), Tag);
|
2022-06-10 09:35:29 -04:00
|
|
|
}
|
2021-02-22 13:36:33 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Names.Sort();
|
|
|
|
|
|
|
|
|
|
OutNameList.Reset();
|
2023-09-28 09:19:30 -04:00
|
|
|
OutNameList.Add(MakeShared<FRigVMStringWithTag>(FName(NAME_None).ToString()));
|
|
|
|
|
for (const FRigVMStringWithTag& Name : Names)
|
2021-02-22 13:36:33 -04:00
|
|
|
{
|
2023-09-28 09:19:30 -04:00
|
|
|
OutNameList.Add(MakeShared<FRigVMStringWithTag>(Name));
|
2021-02-22 13:36:33 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-17 19:12:19 -04:00
|
|
|
template<class T>
|
2023-09-28 09:19:30 -04:00
|
|
|
void CacheNameList(const T& ElementList, TArray<TSharedPtr<FRigVMStringWithTag>>& 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();
|
2023-09-28 09:19:30 -04:00
|
|
|
OutNameList.Add(MakeShared<FRigVMStringWithTag>(FName(NAME_None).ToString()));
|
2019-09-17 19:12:19 -04:00
|
|
|
for (const FString& Name : Names)
|
|
|
|
|
{
|
2023-09-28 09:19:30 -04:00
|
|
|
OutNameList.Add(MakeShared<FRigVMStringWithTag>(Name));
|
2019-09-17 19:12:19 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-28 09:19:30 -04:00
|
|
|
TMap<ERigElementType, TArray<TSharedPtr<FRigVMStringWithTag>>> ElementNameLists;
|
|
|
|
|
TArray<TSharedPtr<FRigVMStringWithTag>> ControlNameListWithoutAnimationChannels;
|
|
|
|
|
TArray<TSharedPtr<FRigVMStringWithTag>> DrawingNameList;
|
|
|
|
|
TArray<TSharedPtr<FRigVMStringWithTag>> ShapeNameList;
|
2021-05-06 09:44:01 -04:00
|
|
|
int32 LastHierarchyTopologyVersion;
|
2020-01-22 17:58:55 -05:00
|
|
|
|
2023-09-28 09:19:30 -04:00
|
|
|
static TArray<TSharedPtr<FRigVMStringWithTag>> EmptyElementNameList;
|
2023-06-15 11:30:29 -04:00
|
|
|
|
|
|
|
|
#endif
|
2022-06-22 08:37:48 -04:00
|
|
|
|
2020-01-22 17:58:55 -05:00
|
|
|
friend class UControlRigGraphNode;
|
|
|
|
|
friend class FControlRigEditor;
|
2023-06-21 05:47:17 -04:00
|
|
|
friend class SRigVMGraphNode;
|
2021-01-26 04:06:19 -04:00
|
|
|
friend class UControlRigBlueprint;
|
2018-04-12 16:57:51 -04:00
|
|
|
};
|
|
|
|
|
|
2022-06-10 09:35:29 -04:00
|
|
|
template<>
|
|
|
|
|
inline bool UControlRigGraph::IncludeElementInNameList<FRigControlElement>(const FRigControlElement* InElement)
|
|
|
|
|
{
|
|
|
|
|
return !InElement->IsAnimationChannel();
|
|
|
|
|
}
|