2020-01-07 17:07:47 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2019-12-13 11:07:03 -05:00
|
|
|
|
|
|
|
|
#include "AnimationNodes/SGraphNodeBlendSpacePlayer.h"
|
2021-01-25 08:43:19 -04:00
|
|
|
#include "SBlendSpacePreview.h"
|
|
|
|
|
#include "AnimGraphNode_Base.h"
|
2021-01-06 09:11:59 -04:00
|
|
|
#include "AnimGraphNode_BlendSpacePlayer.h"
|
2021-01-25 08:43:19 -04:00
|
|
|
#include "Kismet2/BlueprintEditorUtils.h"
|
2021-09-06 07:59:41 -04:00
|
|
|
#include "SLevelOfDetailBranchNode.h"
|
|
|
|
|
#include "Widgets/Layout/SSpacer.h"
|
2019-12-13 11:07:03 -05:00
|
|
|
|
|
|
|
|
void SGraphNodeBlendSpacePlayer::Construct(const FArguments& InArgs, UAnimGraphNode_Base* InNode)
|
|
|
|
|
{
|
|
|
|
|
this->GraphNode = InNode;
|
|
|
|
|
|
|
|
|
|
this->SetCursor(EMouseCursor::CardinalCross);
|
|
|
|
|
|
|
|
|
|
this->UpdateGraphNode();
|
|
|
|
|
|
2021-01-06 09:11:59 -04:00
|
|
|
CachedSyncGroupName = NAME_None;
|
|
|
|
|
|
2019-12-13 11:07:03 -05:00
|
|
|
SAnimationGraphNode::Construct(SAnimationGraphNode::FArguments(), InNode);
|
|
|
|
|
|
|
|
|
|
RegisterActiveTimer(1.0f / 60.0f, FWidgetActiveTimerDelegate::CreateLambda([this](double InCurrentTime, float InDeltaTime)
|
|
|
|
|
{
|
2021-01-06 09:11:59 -04:00
|
|
|
UpdateGraphSyncLabel();
|
2019-12-13 11:07:03 -05:00
|
|
|
return EActiveTimerReturnType::Continue;
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-06 07:59:41 -04:00
|
|
|
void SGraphNodeBlendSpacePlayer::CreateBelowPinControls(TSharedPtr<SVerticalBox> MainBox)
|
2019-12-13 11:07:03 -05:00
|
|
|
{
|
2021-09-06 07:59:41 -04:00
|
|
|
SAnimationGraphNode::CreateBelowPinControls(MainBox);
|
|
|
|
|
|
2021-09-09 11:41:13 -04:00
|
|
|
// Insert above the error reporting bar (but above the tag/functions)
|
|
|
|
|
MainBox->InsertSlot(FMath::Max(0, MainBox->NumSlots() - DebugGridSlotReverseIndex))
|
2019-12-13 11:07:03 -05:00
|
|
|
.AutoHeight()
|
|
|
|
|
.VAlign(VAlign_Fill)
|
|
|
|
|
.Padding(0.0f)
|
|
|
|
|
[
|
2021-09-06 07:59:41 -04:00
|
|
|
SNew(SLevelOfDetailBranchNode)
|
|
|
|
|
.UseLowDetailSlot(this, &SGraphNodeBlendSpacePlayer::UseLowDetailNodeTitles)
|
|
|
|
|
.LowDetail()
|
|
|
|
|
[
|
|
|
|
|
SNew(SSpacer)
|
|
|
|
|
.Size(FVector2D(100.0f, 100.f))
|
|
|
|
|
]
|
|
|
|
|
.HighDetail()
|
|
|
|
|
[
|
|
|
|
|
SNew(SBlendSpacePreview, CastChecked<UAnimGraphNode_Base>(GraphNode))
|
|
|
|
|
]
|
2019-12-13 11:07:03 -05:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-06 09:11:59 -04:00
|
|
|
void SGraphNodeBlendSpacePlayer::UpdateGraphSyncLabel()
|
|
|
|
|
{
|
|
|
|
|
if (UAnimGraphNode_BlendSpacePlayer* VisualBlendSpacePlayer = Cast<UAnimGraphNode_BlendSpacePlayer>(GraphNode))
|
|
|
|
|
{
|
|
|
|
|
FName CurrentSyncGroupName = NAME_None;
|
|
|
|
|
|
|
|
|
|
if (UAnimBlueprint* AnimBlueprint = Cast<UAnimBlueprint>(FBlueprintEditorUtils::FindBlueprintForNode(GraphNode)))
|
|
|
|
|
{
|
|
|
|
|
if(UAnimBlueprintGeneratedClass* GeneratedClass = AnimBlueprint->GetAnimBlueprintGeneratedClass())
|
|
|
|
|
{
|
|
|
|
|
if (UObject* ActiveObject = AnimBlueprint->GetObjectBeingDebugged())
|
|
|
|
|
{
|
2021-04-22 04:57:09 -04:00
|
|
|
if(VisualBlendSpacePlayer->Node.GetGroupMethod() == EAnimSyncMethod::Graph)
|
2021-01-06 09:11:59 -04:00
|
|
|
{
|
|
|
|
|
int32 NodeIndex = GeneratedClass->GetNodeIndexFromGuid(VisualBlendSpacePlayer->NodeGuid);
|
|
|
|
|
if(NodeIndex != INDEX_NONE)
|
|
|
|
|
{
|
|
|
|
|
if(const FName* SyncGroupNamePtr = GeneratedClass->GetAnimBlueprintDebugData().NodeSyncsThisFrame.Find(NodeIndex))
|
|
|
|
|
{
|
|
|
|
|
CurrentSyncGroupName = *SyncGroupNamePtr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(CachedSyncGroupName != CurrentSyncGroupName)
|
|
|
|
|
{
|
|
|
|
|
// Invalidate the node title so we can dynamically display the sync group gleaned from the graph
|
|
|
|
|
VisualBlendSpacePlayer->OnNodeTitleChangedEvent().Broadcast();
|
|
|
|
|
CachedSyncGroupName = CurrentSyncGroupName;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-25 08:43:19 -04:00
|
|
|
}
|