Files
UnrealEngineUWP/Engine/Source/Editor/AnimationBlueprintEditor/Private/AnimationNodes/SGraphNodeBlendSpacePlayer.cpp
Thomas Sarkanen a8c165387c Anim node references
Added the abiity to tag and retrieve any anim graph node (similar to how we could reference linked anim graph nodes previously).
Ported linked anim graph nodes to use the new system
Added the ability to reference any anim graph node by tag (via a new custom node, spawnable from the context menu, with the appearance of an actor reference in a level blueprint)
Added tag display and editing in the bottom-right of anim graph nodes
Added new override point to SGraphNodeK2Var to allow for title widget parameters to be overriden by child classes

#jira UE-126286 - Anim node functions: Add anim node references
#rb Jurre.deBaare
#preflight 613a1e0cf9a522000143c253

[CL 17472894 by Thomas Sarkanen in ue5-main branch]
2021-09-09 11:41:13 -04:00

89 lines
2.7 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "AnimationNodes/SGraphNodeBlendSpacePlayer.h"
#include "SBlendSpacePreview.h"
#include "AnimGraphNode_Base.h"
#include "AnimGraphNode_BlendSpacePlayer.h"
#include "Kismet2/BlueprintEditorUtils.h"
#include "SLevelOfDetailBranchNode.h"
#include "Widgets/Layout/SSpacer.h"
void SGraphNodeBlendSpacePlayer::Construct(const FArguments& InArgs, UAnimGraphNode_Base* InNode)
{
this->GraphNode = InNode;
this->SetCursor(EMouseCursor::CardinalCross);
this->UpdateGraphNode();
CachedSyncGroupName = NAME_None;
SAnimationGraphNode::Construct(SAnimationGraphNode::FArguments(), InNode);
RegisterActiveTimer(1.0f / 60.0f, FWidgetActiveTimerDelegate::CreateLambda([this](double InCurrentTime, float InDeltaTime)
{
UpdateGraphSyncLabel();
return EActiveTimerReturnType::Continue;
}));
}
void SGraphNodeBlendSpacePlayer::CreateBelowPinControls(TSharedPtr<SVerticalBox> MainBox)
{
SAnimationGraphNode::CreateBelowPinControls(MainBox);
// Insert above the error reporting bar (but above the tag/functions)
MainBox->InsertSlot(FMath::Max(0, MainBox->NumSlots() - DebugGridSlotReverseIndex))
.AutoHeight()
.VAlign(VAlign_Fill)
.Padding(0.0f)
[
SNew(SLevelOfDetailBranchNode)
.UseLowDetailSlot(this, &SGraphNodeBlendSpacePlayer::UseLowDetailNodeTitles)
.LowDetail()
[
SNew(SSpacer)
.Size(FVector2D(100.0f, 100.f))
]
.HighDetail()
[
SNew(SBlendSpacePreview, CastChecked<UAnimGraphNode_Base>(GraphNode))
]
];
}
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())
{
if(VisualBlendSpacePlayer->Node.GetGroupMethod() == EAnimSyncMethod::Graph)
{
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;
}
}
}