You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Added a new animation graph node that hosts its own UBlendSpaceBase. Modified UBlendSpaceBase to allow for pose links to be evaluated as the sample points. The new blend space graphs can be spawned from existing UBlendSpace and UBlendSpace1D assets, or they can be created from scratch, or they can be converted from existing blendspace player nodes via the context menu. Fixed anim node conversion functions so that their transactions work correctly. Updated FBlueprintEditorUtils::IsGraphNameUnique to allow it to work with any object as the outer, not just UBlueprint. UBlueprint still has a special case for functions and events. This is to support GenerateUniqueGraphName within a scope (e.g. an outer graph). Formalized the concept of 'node sub-graphs' (as well as the composite node pattern a little). Previously a number of known node types that contained sub-graphs (e.g. UK2Node_Composite) had special case logic for dealing with node/graph deletion etc. Now any node can opt into this behaviour via the GetSubGraphs() override. Added status bar readouts for the blendspace grid, so we dont have to stuff the prompts into the tooltip any more. Moved anim BP related APIs out of FBlueprintEditor. They are always used via FAnimationBlueprintEditor. Refactored graph title bar widget creation out into a function to allow other document tab factories to create it. Altered breadcrumb trail click callbacks and SMyBlueprint::ExecuteAction to always JumpToHyperLink rather than calling OpenDocument directly. This allows unknown (to FBlueprintEditor) document types that reference objects to be correctly jumped to using the breadcrumb trail. Derived asset editors (i.e. FAnimationBlueprintEditor) can intercept the JumpToHyperlink call to ensure that the correct document is presented (i.e. the correct tab payload is generated). Instead of making yet another bunch of duplicated code for handling the various alpha blend options, refactored this into FAnimGraphNodeAlphaOptions (for editor code) and FAnimNodeAlphaOptions (for runtime code). Added OnCopyTermDefaultsToDefaultObject for per-node copying of default values from editor node to runtime node, rather than another special-case in the compiler. #rb Jurre.deBaare,Phillip.Kavan [CL 15177316 by Thomas Sarkanen in ue5-main branch]
213 lines
6.7 KiB
C++
213 lines
6.7 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "AnimGraphNode_SequenceEvaluator.h"
|
|
#include "ToolMenus.h"
|
|
|
|
#include "Kismet2/CompilerResultsLog.h"
|
|
#include "AnimGraphCommands.h"
|
|
#include "Animation/AnimComposite.h"
|
|
#include "Animation/AnimSequence.h"
|
|
#include "AnimGraphNode_SequenceEvaluator.h"
|
|
|
|
/////////////////////////////////////////////////////
|
|
// UAnimGraphNode_SequenceEvaluator
|
|
|
|
#define LOCTEXT_NAMESPACE "A3Nodes"
|
|
|
|
UAnimGraphNode_SequenceEvaluator::UAnimGraphNode_SequenceEvaluator(const FObjectInitializer& ObjectInitializer)
|
|
: Super(ObjectInitializer)
|
|
{
|
|
}
|
|
|
|
void UAnimGraphNode_SequenceEvaluator::PreloadRequiredAssets()
|
|
{
|
|
PreloadObject(Node.Sequence);
|
|
|
|
Super::PreloadRequiredAssets();
|
|
}
|
|
|
|
void UAnimGraphNode_SequenceEvaluator::BakeDataDuringCompilation(class FCompilerResultsLog& MessageLog)
|
|
{
|
|
UAnimBlueprint* AnimBlueprint = GetAnimBlueprint();
|
|
AnimBlueprint->FindOrAddGroup(SyncGroup.GroupName);
|
|
Node.GroupName = SyncGroup.GroupName;
|
|
Node.GroupRole = SyncGroup.GroupRole;
|
|
Node.Method = SyncGroup.Method;
|
|
}
|
|
|
|
void UAnimGraphNode_SequenceEvaluator::GetAllAnimationSequencesReferred(TArray<UAnimationAsset*>& AnimationAssets) const
|
|
{
|
|
if(Node.Sequence)
|
|
{
|
|
HandleAnimReferenceCollection(Node.Sequence, AnimationAssets);
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_SequenceEvaluator::ReplaceReferredAnimations(const TMap<UAnimationAsset*, UAnimationAsset*>& AnimAssetReplacementMap)
|
|
{
|
|
HandleAnimReferenceReplacement(Node.Sequence, AnimAssetReplacementMap);
|
|
}
|
|
|
|
FText UAnimGraphNode_SequenceEvaluator::GetTooltipText() const
|
|
{
|
|
// FText::Format() is slow, so we utilize the cached list title
|
|
return GetNodeTitle(ENodeTitleType::ListView);
|
|
}
|
|
|
|
FText UAnimGraphNode_SequenceEvaluator::GetNodeTitleForSequence(ENodeTitleType::Type TitleType, UAnimSequenceBase* InSequence) const
|
|
{
|
|
const FText SequenceName = FText::FromString(InSequence->GetName());
|
|
|
|
FFormatNamedArguments Args;
|
|
Args.Add(TEXT("SequenceName"), SequenceName);
|
|
|
|
// FText::Format() is slow, so we cache this to save on performance
|
|
if (InSequence->IsValidAdditive())
|
|
{
|
|
CachedNodeTitle.SetCachedText(FText::Format(LOCTEXT("EvaluateSequence_Additive", "Evaluate {SequenceName} (additive)"), Args), this);
|
|
}
|
|
else
|
|
{
|
|
CachedNodeTitle.SetCachedText(FText::Format(LOCTEXT("EvaluateSequence", "Evaluate {SequenceName}"), Args), this);
|
|
}
|
|
|
|
return CachedNodeTitle;
|
|
}
|
|
|
|
FText UAnimGraphNode_SequenceEvaluator::GetNodeTitle(ENodeTitleType::Type TitleType) const
|
|
{
|
|
if (Node.Sequence == nullptr)
|
|
{
|
|
// we may have a valid variable connected or default pin value
|
|
UEdGraphPin* SequencePin = FindPin(GET_MEMBER_NAME_STRING_CHECKED(FAnimNode_SequenceEvaluator, Sequence));
|
|
if (SequencePin && SequencePin->LinkedTo.Num() > 0)
|
|
{
|
|
return LOCTEXT("EvaluateSequence_TitleVariable", "Evaluate Animation Sequence");
|
|
}
|
|
else if (SequencePin && SequencePin->DefaultObject != nullptr)
|
|
{
|
|
return GetNodeTitleForSequence(TitleType, CastChecked<UAnimSequenceBase>(SequencePin->DefaultObject));
|
|
}
|
|
else
|
|
{
|
|
return LOCTEXT("EvaluateSequence_TitleNONE", "Evaluate (None)");
|
|
}
|
|
}
|
|
// @TODO: don't know enough about this node type to comfortably assert that
|
|
// the CacheName won't change after the node has spawned... until
|
|
// then, we'll leave this optimization off
|
|
else //if (CachedNodeTitle.IsOutOfDate(this))
|
|
{
|
|
GetNodeTitleForSequence(TitleType, Node.Sequence);
|
|
}
|
|
|
|
return CachedNodeTitle;
|
|
}
|
|
|
|
void UAnimGraphNode_SequenceEvaluator::GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const
|
|
{
|
|
// Intentionally empty; you can drop down a regular sequence player and convert into a sequence evaluator in the right-click menu.
|
|
}
|
|
|
|
void UAnimGraphNode_SequenceEvaluator::SetAnimationAsset(UAnimationAsset* Asset)
|
|
{
|
|
if (UAnimSequenceBase* Seq = Cast<UAnimSequence>(Asset))
|
|
{
|
|
Node.Sequence = Seq;
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_SequenceEvaluator::ValidateAnimNodeDuringCompilation(class USkeleton* ForSkeleton, class FCompilerResultsLog& MessageLog)
|
|
{
|
|
Super::ValidateAnimNodeDuringCompilation(ForSkeleton, MessageLog);
|
|
|
|
UAnimSequenceBase* SequenceToCheck = Node.Sequence;
|
|
UEdGraphPin* SequencePin = FindPin(GET_MEMBER_NAME_STRING_CHECKED(FAnimNode_SequenceEvaluator, Sequence));
|
|
if (SequencePin != nullptr && SequenceToCheck == nullptr)
|
|
{
|
|
SequenceToCheck = Cast<UAnimSequenceBase>(SequencePin->DefaultObject);
|
|
}
|
|
|
|
if (SequenceToCheck == nullptr)
|
|
{
|
|
// Check for bindings
|
|
bool bHasBinding = false;
|
|
if(SequencePin != nullptr)
|
|
{
|
|
if (FAnimGraphNodePropertyBinding* BindingPtr = PropertyBindings.Find(SequencePin->GetFName()))
|
|
{
|
|
bHasBinding = true;
|
|
}
|
|
}
|
|
|
|
// we may have a connected node or binding
|
|
if (SequencePin == nullptr || (SequencePin->LinkedTo.Num() == 0 && !bHasBinding))
|
|
{
|
|
MessageLog.Error(TEXT("@@ references an unknown sequence"), this);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
USkeleton* SeqSkeleton = SequenceToCheck->GetSkeleton();
|
|
if (SeqSkeleton&& // if anim sequence doesn't have skeleton, it might be due to anim sequence not loaded yet, @todo: wait with anim blueprint compilation until all assets are loaded?
|
|
!SeqSkeleton->IsCompatible(ForSkeleton))
|
|
{
|
|
MessageLog.Error(TEXT("@@ references sequence that uses different skeleton @@"), this, SeqSkeleton);
|
|
}
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_SequenceEvaluator::GetNodeContextMenuActions(UToolMenu* Menu, UGraphNodeContextMenuContext* Context) const
|
|
{
|
|
if (!Context->bIsDebugging)
|
|
{
|
|
// add an option to convert to a regular sequence player
|
|
{
|
|
FToolMenuSection& Section = Menu->AddSection("AnimGraphNodeSequenceEvaluator", NSLOCTEXT("A3Nodes", "SequenceEvaluatorHeading", "Sequence Evaluator"));
|
|
Section.AddMenuEntry(FAnimGraphCommands::Get().OpenRelatedAsset);
|
|
Section.AddMenuEntry(FAnimGraphCommands::Get().ConvertToSeqPlayer);
|
|
}
|
|
}
|
|
}
|
|
|
|
bool UAnimGraphNode_SequenceEvaluator::DoesSupportTimeForTransitionGetter() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
UAnimationAsset* UAnimGraphNode_SequenceEvaluator::GetAnimationAsset() const
|
|
{
|
|
UAnimSequenceBase* Sequence = Node.Sequence;
|
|
UEdGraphPin* SequencePin = FindPin(GET_MEMBER_NAME_STRING_CHECKED(FAnimNode_SequenceEvaluator, Sequence));
|
|
if (SequencePin != nullptr && Sequence == nullptr)
|
|
{
|
|
Sequence = Cast<UAnimSequenceBase>(SequencePin->DefaultObject);
|
|
}
|
|
|
|
return Node.Sequence;
|
|
}
|
|
|
|
const TCHAR* UAnimGraphNode_SequenceEvaluator::GetTimePropertyName() const
|
|
{
|
|
return TEXT("ExplicitTime");
|
|
}
|
|
|
|
UScriptStruct* UAnimGraphNode_SequenceEvaluator::GetTimePropertyStruct() const
|
|
{
|
|
return FAnimNode_SequenceEvaluator::StaticStruct();
|
|
}
|
|
|
|
EAnimAssetHandlerType UAnimGraphNode_SequenceEvaluator::SupportsAssetClass(const UClass* AssetClass) const
|
|
{
|
|
if (AssetClass->IsChildOf(UAnimSequence::StaticClass()) || AssetClass->IsChildOf(UAnimComposite::StaticClass()))
|
|
{
|
|
return EAnimAssetHandlerType::Supported;
|
|
}
|
|
else
|
|
{
|
|
return EAnimAssetHandlerType::NotSupported;
|
|
}
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE
|