You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
1) Root motion delta flow supported through all anim nodes deriving from FAnimNode_AssetPlayerBase and montages. 2) Stride/Orientation warping feature graph-driven evaluation modes which leverage root motion delta flow (graph-driven slope warping currently disabled). 3) Root motion flow connected to the Animation Warping plugin. 4) Pose Warping test map featuring various motion "styles" connected to pose warping (Motion Matching, Blend Space Graphs/Assets, Sequence Players, Evaluators). #preflight 6092380a58c4790001a3e9b6 #rb aaron.cox, braeden.shosa, thomas.sarkanen #jira none #fyi laurent.delayen [CL 16208667 by koray hagen in ue5-main branch]
574 lines
20 KiB
C++
574 lines
20 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "AnimGraphNode_SequencePlayer.h"
|
|
#include "EdGraphSchema_K2_Actions.h"
|
|
#include "Modules/ModuleManager.h"
|
|
#include "ToolMenus.h"
|
|
|
|
#include "Kismet2/CompilerResultsLog.h"
|
|
#include "AnimGraphCommands.h"
|
|
#include "ARFilter.h"
|
|
#include "AssetRegistryModule.h"
|
|
#include "BlueprintActionFilter.h"
|
|
#include "BlueprintActionDatabaseRegistrar.h"
|
|
#include "BlueprintNodeSpawner.h"
|
|
#include "DetailLayoutBuilder.h"
|
|
#include "EditorCategoryUtils.h"
|
|
#include "Animation/AnimComposite.h"
|
|
#include "Animation/AnimSequence.h"
|
|
#include "Animation/AnimPoseSearchProvider.h"
|
|
#include "Animation/AnimRootMotionProvider.h"
|
|
#include "UObject/UE5MainStreamObjectVersion.h"
|
|
#include "IAnimBlueprintNodeOverrideAssetsContext.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "A3Nodes"
|
|
|
|
/////////////////////////////////////////////////////
|
|
// FNewSequencePlayerAction
|
|
|
|
// Action to add a sequence player node to the graph
|
|
struct FNewSequencePlayerAction : public FEdGraphSchemaAction_K2NewNode
|
|
{
|
|
protected:
|
|
FAssetData AssetInfo;
|
|
public:
|
|
FNewSequencePlayerAction(const FAssetData& InAssetInfo, FText Title)
|
|
: FEdGraphSchemaAction_K2NewNode(LOCTEXT("Animation", "Animations"), Title, LOCTEXT("EvalAnimSequenceToMakePose", "Evaluates an animation sequence to produce a pose"), 0, FText::FromName(InAssetInfo.ObjectPath))
|
|
{
|
|
AssetInfo = InAssetInfo;
|
|
|
|
UAnimGraphNode_SequencePlayer* Template = NewObject<UAnimGraphNode_SequencePlayer>();
|
|
NodeTemplate = Template;
|
|
}
|
|
|
|
virtual UEdGraphNode* PerformAction(class UEdGraph* ParentGraph, UEdGraphPin* FromPin, const FVector2D Location, bool bSelectNewNode = true) override
|
|
{
|
|
UAnimGraphNode_SequencePlayer* SpawnedNode = CastChecked<UAnimGraphNode_SequencePlayer>(FEdGraphSchemaAction_K2NewNode::PerformAction(ParentGraph, FromPin, Location, bSelectNewNode));
|
|
SpawnedNode->Node.SetSequence(Cast<UAnimSequence>(AssetInfo.GetAsset()));
|
|
|
|
return SpawnedNode;
|
|
}
|
|
};
|
|
|
|
/////////////////////////////////////////////////////
|
|
// UAnimGraphNode_SequencePlayer
|
|
|
|
UAnimGraphNode_SequencePlayer::UAnimGraphNode_SequencePlayer(const FObjectInitializer& ObjectInitializer)
|
|
: Super(ObjectInitializer)
|
|
{
|
|
}
|
|
|
|
void UAnimGraphNode_SequencePlayer::Serialize(FArchive& Ar)
|
|
{
|
|
Super::Serialize(Ar);
|
|
|
|
Ar.UsingCustomVersion(FUE5MainStreamObjectVersion::GUID);
|
|
|
|
if(Ar.IsLoading() && Ar.CustomVer(FUE5MainStreamObjectVersion::GUID) < FUE5MainStreamObjectVersion::AnimNodeConstantDataRefactorPhase0)
|
|
{
|
|
Node.PlayRateScaleBiasClampConstants.CopyFromLegacy(Node.PlayRateScaleBiasClamp_DEPRECATED);
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_SequencePlayer::PreloadRequiredAssets()
|
|
{
|
|
PreloadObject(Node.GetSequence());
|
|
|
|
Super::PreloadRequiredAssets();
|
|
}
|
|
|
|
FLinearColor UAnimGraphNode_SequencePlayer::GetNodeTitleColor() const
|
|
{
|
|
UAnimSequenceBase* Sequence = Node.GetSequence();
|
|
if ((Sequence != NULL) && Sequence->IsValidAdditive())
|
|
{
|
|
return FLinearColor(0.10f, 0.60f, 0.12f);
|
|
}
|
|
else
|
|
{
|
|
return FColor(200, 100, 100);
|
|
}
|
|
}
|
|
|
|
FText UAnimGraphNode_SequencePlayer::GetTooltipText() const
|
|
{
|
|
UAnimSequenceBase* Sequence = Node.GetSequence();
|
|
if (!Sequence)
|
|
{
|
|
return FText();
|
|
}
|
|
|
|
const bool bAdditive = Sequence->IsValidAdditive();
|
|
return GetTitleGivenAssetInfo(FText::FromString(Sequence->GetPathName()), bAdditive);
|
|
}
|
|
|
|
FText UAnimGraphNode_SequencePlayer::GetNodeTitleForSequence(ENodeTitleType::Type TitleType, UAnimSequenceBase* InSequence) const
|
|
{
|
|
const bool bAdditive = InSequence->IsValidAdditive();
|
|
const FText BasicTitle = GetTitleGivenAssetInfo(FText::FromName(InSequence->GetFName()), bAdditive);
|
|
|
|
if(Node.GetGroupMethod() == EAnimSyncMethod::SyncGroup)
|
|
{
|
|
const FText SyncGroupName = FText::FromName(Node.GetGroupName());
|
|
|
|
FFormatNamedArguments Args;
|
|
Args.Add(TEXT("Title"), BasicTitle);
|
|
Args.Add(TEXT("SyncGroup"), SyncGroupName);
|
|
|
|
if (TitleType == ENodeTitleType::FullTitle)
|
|
{
|
|
return FText::Format(LOCTEXT("SequenceNodeGroupWithSubtitleFull", "{Title}\nSync group {SyncGroup}"), Args);
|
|
}
|
|
else
|
|
{
|
|
return FText::Format(LOCTEXT("SequenceNodeGroupWithSubtitleList", "{Title} (Sync group {SyncGroup})"), Args);
|
|
}
|
|
}
|
|
else if(Node.GetGroupMethod() == EAnimSyncMethod::Graph)
|
|
{
|
|
FFormatNamedArguments Args;
|
|
Args.Add(TEXT("Title"), BasicTitle);
|
|
|
|
UObject* ObjectBeingDebugged = GetAnimBlueprint()->GetObjectBeingDebugged();
|
|
UAnimBlueprintGeneratedClass* GeneratedClass = GetAnimBlueprint()->GetAnimBlueprintGeneratedClass();
|
|
if (ObjectBeingDebugged && GeneratedClass)
|
|
{
|
|
int32 NodeIndex = GeneratedClass->GetNodeIndexFromGuid(NodeGuid);
|
|
if(NodeIndex != INDEX_NONE)
|
|
{
|
|
if(const FName* SyncGroupNamePtr = GeneratedClass->GetAnimBlueprintDebugData().NodeSyncsThisFrame.Find(NodeIndex))
|
|
{
|
|
Args.Add(TEXT("SyncGroup"), FText::FromName(*SyncGroupNamePtr));
|
|
|
|
if (TitleType == ENodeTitleType::FullTitle)
|
|
{
|
|
return FText::Format(LOCTEXT("SequenceNodeGraphSyncDebuggedWithSubtitleFull", "{Title}\nGraph sync group {SyncGroup}"), Args);
|
|
}
|
|
else
|
|
{
|
|
return FText::Format(LOCTEXT("SequenceNodeGraphSyncDebuggedWithSubtitleList", "{Title} (Graph sync group {SyncGroup})"), Args);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Indicate that the sync is graph-based if we have no debug data
|
|
if (TitleType == ENodeTitleType::FullTitle)
|
|
{
|
|
return FText::Format(LOCTEXT("SequenceNodeGraphSyncWithSubtitleFull", "{Title}\nGraph sync group"), Args);
|
|
}
|
|
else
|
|
{
|
|
return FText::Format(LOCTEXT("SequenceNodeGraphSyncWithSubtitleList", "{Title} (Graph sync group)"), Args);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return BasicTitle;
|
|
}
|
|
}
|
|
|
|
FText UAnimGraphNode_SequencePlayer::GetNodeTitle(ENodeTitleType::Type TitleType) const
|
|
{
|
|
UAnimSequenceBase* Sequence = Node.GetSequence();
|
|
if (Sequence == nullptr)
|
|
{
|
|
// we may have a valid variable connected or default pin value
|
|
UEdGraphPin* SequencePin = FindPin(GET_MEMBER_NAME_STRING_CHECKED(FAnimNode_SequencePlayer, Sequence));
|
|
if (SequencePin && SequencePin->LinkedTo.Num() > 0)
|
|
{
|
|
return LOCTEXT("SequenceNodeTitleVariable", "Play Animation Sequence");
|
|
}
|
|
else if (SequencePin && SequencePin->DefaultObject != nullptr)
|
|
{
|
|
return GetNodeTitleForSequence(TitleType, CastChecked<UAnimSequenceBase>(SequencePin->DefaultObject));
|
|
}
|
|
else
|
|
{
|
|
return LOCTEXT("SequenceNullTitle", "Play (None)");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return GetNodeTitleForSequence(TitleType, Sequence);
|
|
}
|
|
}
|
|
|
|
FText UAnimGraphNode_SequencePlayer::GetTitleGivenAssetInfo(const FText& AssetName, bool bKnownToBeAdditive)
|
|
{
|
|
FFormatNamedArguments Args;
|
|
Args.Add(TEXT("AssetName"), AssetName);
|
|
|
|
if (bKnownToBeAdditive)
|
|
{
|
|
return FText::Format(LOCTEXT("SequenceNodeTitleAdditive", "Play {AssetName} (additive)"), Args);
|
|
}
|
|
else
|
|
{
|
|
return FText::Format(LOCTEXT("SequenceNodeTitle", "Play {AssetName}"), Args);
|
|
}
|
|
}
|
|
|
|
FText UAnimGraphNode_SequencePlayer::GetMenuCategory() const
|
|
{
|
|
return FEditorCategoryUtils::GetCommonCategory(FCommonEditorCategory::Animation);
|
|
}
|
|
|
|
void UAnimGraphNode_SequencePlayer::GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const
|
|
{
|
|
auto LoadedAssetSetup = [](UEdGraphNode* NewNode, bool /*bIsTemplateNode*/, TWeakObjectPtr<UAnimSequence> SequencePtr)
|
|
{
|
|
UAnimGraphNode_SequencePlayer* SequencePlayerNode = CastChecked<UAnimGraphNode_SequencePlayer>(NewNode);
|
|
SequencePlayerNode->Node.SetSequence(SequencePtr.Get());
|
|
};
|
|
|
|
auto UnloadedAssetSetup = [](UEdGraphNode* NewNode, bool bIsTemplateNode, const FAssetData AssetData)
|
|
{
|
|
UAnimGraphNode_SequencePlayer* SequencePlayerNode = CastChecked<UAnimGraphNode_SequencePlayer>(NewNode);
|
|
if (bIsTemplateNode)
|
|
{
|
|
AssetData.GetTagValue("Skeleton", SequencePlayerNode->UnloadedSkeletonName);
|
|
}
|
|
else
|
|
{
|
|
UAnimSequence* Sequence = Cast<UAnimSequence>(AssetData.GetAsset());
|
|
check(Sequence != nullptr);
|
|
SequencePlayerNode->Node.SetSequence(Sequence);
|
|
}
|
|
};
|
|
|
|
const UObject* QueryObject = ActionRegistrar.GetActionKeyFilter();
|
|
if (QueryObject == nullptr)
|
|
{
|
|
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
|
|
// define a filter to help in pulling UAnimSequence asset data from the registry
|
|
FARFilter Filter;
|
|
Filter.ClassNames.Add(UAnimSequence::StaticClass()->GetFName());
|
|
Filter.bRecursiveClasses = true;
|
|
// Find matching assets and add an entry for each one
|
|
TArray<FAssetData> SequenceList;
|
|
AssetRegistryModule.Get().GetAssets(Filter, /*out*/SequenceList);
|
|
|
|
for (auto AssetIt = SequenceList.CreateConstIterator(); AssetIt; ++AssetIt)
|
|
{
|
|
const FAssetData& Asset = *AssetIt;
|
|
|
|
UBlueprintNodeSpawner* NodeSpawner = UBlueprintNodeSpawner::Create(GetClass());
|
|
if (Asset.IsAssetLoaded())
|
|
{
|
|
UAnimSequence* AnimSequence = Cast<UAnimSequence>(Asset.GetAsset());
|
|
if(AnimSequence)
|
|
{
|
|
NodeSpawner->CustomizeNodeDelegate = UBlueprintNodeSpawner::FCustomizeNodeDelegate::CreateStatic(LoadedAssetSetup, TWeakObjectPtr<UAnimSequence>(AnimSequence));
|
|
NodeSpawner->DefaultMenuSignature.MenuName = GetTitleGivenAssetInfo(FText::FromName(AnimSequence->GetFName()), AnimSequence->IsValidAdditive());
|
|
NodeSpawner->DefaultMenuSignature.Tooltip = GetTitleGivenAssetInfo(FText::FromString(AnimSequence->GetPathName()), AnimSequence->IsValidAdditive());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
const FString TagValue = Asset.GetTagValueRef<FString>(GET_MEMBER_NAME_CHECKED(UAnimSequence, AdditiveAnimType));
|
|
const bool bKnownToBeAdditive = (!TagValue.IsEmpty() && !TagValue.Equals(TEXT("AAT_None")));
|
|
|
|
NodeSpawner->CustomizeNodeDelegate = UBlueprintNodeSpawner::FCustomizeNodeDelegate::CreateStatic(UnloadedAssetSetup, Asset);
|
|
NodeSpawner->DefaultMenuSignature.MenuName = GetTitleGivenAssetInfo(FText::FromName(Asset.AssetName), bKnownToBeAdditive);
|
|
NodeSpawner->DefaultMenuSignature.Tooltip = GetTitleGivenAssetInfo(FText::FromName(Asset.ObjectPath), bKnownToBeAdditive);
|
|
}
|
|
ActionRegistrar.AddBlueprintAction(Asset, NodeSpawner);
|
|
}
|
|
}
|
|
else if (const UAnimSequence* AnimSequence = Cast<UAnimSequence>(QueryObject))
|
|
{
|
|
UBlueprintNodeSpawner* NodeSpawner = UBlueprintNodeSpawner::Create(GetClass());
|
|
|
|
TWeakObjectPtr<UAnimSequence> SequencePtr = MakeWeakObjectPtr(const_cast<UAnimSequence*>(AnimSequence));
|
|
NodeSpawner->CustomizeNodeDelegate = UBlueprintNodeSpawner::FCustomizeNodeDelegate::CreateStatic(LoadedAssetSetup, SequencePtr);
|
|
NodeSpawner->DefaultMenuSignature.MenuName = GetTitleGivenAssetInfo(FText::FromName(AnimSequence->GetFName()), AnimSequence->IsValidAdditive());
|
|
NodeSpawner->DefaultMenuSignature.Tooltip = GetTitleGivenAssetInfo(FText::FromString(AnimSequence->GetPathName()), AnimSequence->IsValidAdditive());
|
|
|
|
ActionRegistrar.AddBlueprintAction(QueryObject, NodeSpawner);
|
|
}
|
|
else if (QueryObject == GetClass())
|
|
{
|
|
FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
|
|
// define a filter to help in pulling UAnimSequence asset data from the registry
|
|
FARFilter Filter;
|
|
Filter.ClassNames.Add(UAnimSequence::StaticClass()->GetFName());
|
|
Filter.bRecursiveClasses = true;
|
|
// Find matching assets and add an entry for each one
|
|
TArray<FAssetData> SequenceList;
|
|
AssetRegistryModule.Get().GetAssets(Filter, /*out*/SequenceList);
|
|
|
|
for (auto AssetIt = SequenceList.CreateConstIterator(); AssetIt; ++AssetIt)
|
|
{
|
|
const FAssetData& Asset = *AssetIt;
|
|
if (Asset.IsAssetLoaded())
|
|
{
|
|
continue;
|
|
}
|
|
|
|
UBlueprintNodeSpawner* NodeSpawner = UBlueprintNodeSpawner::Create(GetClass());
|
|
NodeSpawner->CustomizeNodeDelegate = UBlueprintNodeSpawner::FCustomizeNodeDelegate::CreateStatic(UnloadedAssetSetup, Asset);
|
|
|
|
const FString TagValue = Asset.GetTagValueRef<FString>(GET_MEMBER_NAME_CHECKED(UAnimSequence, AdditiveAnimType));
|
|
const bool bKnownToBeAdditive = (!TagValue.IsEmpty() && !TagValue.Equals(TEXT("AAT_None")));
|
|
|
|
NodeSpawner->DefaultMenuSignature.MenuName = GetTitleGivenAssetInfo(FText::FromName(Asset.AssetName), bKnownToBeAdditive);
|
|
NodeSpawner->DefaultMenuSignature.Tooltip = GetTitleGivenAssetInfo(FText::FromName(Asset.ObjectPath), bKnownToBeAdditive);
|
|
ActionRegistrar.AddBlueprintAction(Asset, NodeSpawner);
|
|
}
|
|
}
|
|
}
|
|
|
|
bool UAnimGraphNode_SequencePlayer::IsActionFilteredOut(class FBlueprintActionFilter const& Filter)
|
|
{
|
|
bool bIsFilteredOut = false;
|
|
FBlueprintActionContext const& FilterContext = Filter.Context;
|
|
|
|
for (UBlueprint* Blueprint : FilterContext.Blueprints)
|
|
{
|
|
UAnimBlueprint* AnimBlueprint = Cast<UAnimBlueprint>(Blueprint);
|
|
if (AnimBlueprint && AnimBlueprint->TargetSkeleton)
|
|
{
|
|
UAnimSequenceBase* Sequence = Node.GetSequence();
|
|
if(Sequence)
|
|
{
|
|
if (!AnimBlueprint->TargetSkeleton->IsCompatible(Sequence->GetSkeleton()))
|
|
{
|
|
// Asset does not use a compatible skeleton with the Blueprint, cannot use
|
|
bIsFilteredOut = true;
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!AnimBlueprint->TargetSkeleton->IsCompatibleSkeletonByAssetString(UnloadedSkeletonName))
|
|
{
|
|
bIsFilteredOut = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// Not an animation Blueprint or has no target skeleton, cannot use
|
|
bIsFilteredOut = true;
|
|
break;
|
|
}
|
|
}
|
|
return bIsFilteredOut;
|
|
}
|
|
|
|
EAnimAssetHandlerType UAnimGraphNode_SequencePlayer::SupportsAssetClass(const UClass* AssetClass) const
|
|
{
|
|
if (AssetClass->IsChildOf(UAnimSequence::StaticClass()) || AssetClass->IsChildOf(UAnimComposite::StaticClass()))
|
|
{
|
|
return EAnimAssetHandlerType::PrimaryHandler;
|
|
}
|
|
else
|
|
{
|
|
return EAnimAssetHandlerType::NotSupported;
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_SequencePlayer::GetOutputLinkAttributes(FNodeAttributeArray& OutAttributes) const
|
|
{
|
|
Super::GetOutputLinkAttributes(OutAttributes);
|
|
|
|
if (UE::Anim::IAnimRootMotionProvider::Get())
|
|
{
|
|
OutAttributes.Add(UE::Anim::IAnimRootMotionProvider::RootMotionDeltaAttributeName);
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_SequencePlayer::ValidateAnimNodeDuringCompilation(class USkeleton* ForSkeleton, class FCompilerResultsLog& MessageLog)
|
|
{
|
|
Super::ValidateAnimNodeDuringCompilation(ForSkeleton, MessageLog);
|
|
|
|
UAnimSequenceBase* SequenceToCheck = Node.GetSequence();
|
|
UEdGraphPin* SequencePin = FindPin(GET_MEMBER_NAME_STRING_CHECKED(FAnimNode_SequencePlayer, 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 if(SupportsAssetClass(SequenceToCheck->GetClass()) == EAnimAssetHandlerType::NotSupported)
|
|
{
|
|
MessageLog.Error(*FText::Format(LOCTEXT("UnsupportedAssetError", "@@ is trying to play a {0} as a sequence, which is not allowed."), SequenceToCheck->GetClass()->GetDisplayNameText()).ToString(), 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?
|
|
!ForSkeleton->IsCompatible(SeqSkeleton))
|
|
{
|
|
MessageLog.Error(TEXT("@@ references sequence that uses an incompatible skeleton @@"), this, SeqSkeleton);
|
|
}
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_SequencePlayer::GetNodeContextMenuActions(UToolMenu* Menu, UGraphNodeContextMenuContext* Context) const
|
|
{
|
|
if (!Context->bIsDebugging)
|
|
{
|
|
// add an option to convert to single frame
|
|
{
|
|
FToolMenuSection& Section = Menu->AddSection("AnimGraphNodeSequencePlayer", NSLOCTEXT("A3Nodes", "SequencePlayerHeading", "Sequence Player"));
|
|
Section.AddMenuEntry(FAnimGraphCommands::Get().OpenRelatedAsset);
|
|
Section.AddMenuEntry(FAnimGraphCommands::Get().ConvertToSeqEvaluator);
|
|
}
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_SequencePlayer::SetAnimationAsset(UAnimationAsset* Asset)
|
|
{
|
|
if (UAnimSequenceBase* Seq = Cast<UAnimSequenceBase>(Asset))
|
|
{
|
|
Node.SetSequence(Seq);
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_SequencePlayer::OnOverrideAssets(IAnimBlueprintNodeOverrideAssetsContext& InContext) const
|
|
{
|
|
if(InContext.GetAssets().Num() > 0)
|
|
{
|
|
if (UAnimSequenceBase* Sequence = Cast<UAnimSequenceBase>(InContext.GetAssets()[0]))
|
|
{
|
|
FAnimNode_SequencePlayer& AnimNode = InContext.GetAnimNode<FAnimNode_SequencePlayer>();
|
|
AnimNode.SetSequence(Sequence);
|
|
}
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_SequencePlayer::BakeDataDuringCompilation(class FCompilerResultsLog& MessageLog)
|
|
{
|
|
UAnimBlueprint* AnimBlueprint = GetAnimBlueprint();
|
|
AnimBlueprint->FindOrAddGroup(Node.GetGroupName());
|
|
}
|
|
|
|
void UAnimGraphNode_SequencePlayer::GetAllAnimationSequencesReferred(TArray<UAnimationAsset*>& AnimationAssets) const
|
|
{
|
|
if(Node.GetSequence())
|
|
{
|
|
HandleAnimReferenceCollection(Node.Sequence, AnimationAssets);
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_SequencePlayer::ReplaceReferredAnimations(const TMap<UAnimationAsset*, UAnimationAsset*>& AnimAssetReplacementMap)
|
|
{
|
|
HandleAnimReferenceReplacement(Node.Sequence, AnimAssetReplacementMap);
|
|
}
|
|
|
|
|
|
bool UAnimGraphNode_SequencePlayer::DoesSupportTimeForTransitionGetter() const
|
|
{
|
|
return true;
|
|
}
|
|
|
|
UAnimationAsset* UAnimGraphNode_SequencePlayer::GetAnimationAsset() const
|
|
{
|
|
UAnimSequenceBase* Sequence = Node.GetSequence();
|
|
UEdGraphPin* SequencePin = FindPin(GET_MEMBER_NAME_STRING_CHECKED(FAnimNode_SequencePlayer, Sequence));
|
|
if (SequencePin != nullptr && Sequence == nullptr)
|
|
{
|
|
Sequence = Cast<UAnimSequenceBase>(SequencePin->DefaultObject);
|
|
}
|
|
|
|
return Sequence;
|
|
}
|
|
|
|
const TCHAR* UAnimGraphNode_SequencePlayer::GetTimePropertyName() const
|
|
{
|
|
return TEXT("InternalTimeAccumulator");
|
|
}
|
|
|
|
UScriptStruct* UAnimGraphNode_SequencePlayer::GetTimePropertyStruct() const
|
|
{
|
|
return FAnimNode_SequencePlayer::StaticStruct();
|
|
}
|
|
|
|
void UAnimGraphNode_SequencePlayer::CustomizeDetails(IDetailLayoutBuilder& DetailBuilder)
|
|
{
|
|
Super::CustomizeDetails(DetailBuilder);
|
|
|
|
if (!UE::Anim::IPoseSearchProvider::IsAvailable())
|
|
{
|
|
DetailBuilder.HideCategory(TEXT("PoseMatching"));
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_SequencePlayer::CustomizePinData(UEdGraphPin* Pin, FName SourcePropertyName, int32 ArrayIndex) const
|
|
{
|
|
Super::CustomizePinData(Pin, SourcePropertyName, ArrayIndex);
|
|
|
|
if (Pin->PinName == GET_MEMBER_NAME_STRING_CHECKED(FAnimNode_SequencePlayer, PlayRate))
|
|
{
|
|
if (!Pin->bHidden)
|
|
{
|
|
// Draw value for PlayRateBasis if the pin is not exposed
|
|
UEdGraphPin* PlayRateBasisPin = FindPin(GET_MEMBER_NAME_STRING_CHECKED(FAnimNode_SequencePlayer, PlayRateBasis));
|
|
if (!PlayRateBasisPin || PlayRateBasisPin->bHidden)
|
|
{
|
|
if (Node.GetPlayRateBasis() != 1.f)
|
|
{
|
|
FFormatNamedArguments Args;
|
|
Args.Add(TEXT("PinFriendlyName"), Pin->PinFriendlyName);
|
|
Args.Add(TEXT("PlayRateBasis"), FText::AsNumber(Node.GetPlayRateBasis()));
|
|
Pin->PinFriendlyName = FText::Format(LOCTEXT("FAnimNode_SequencePlayer_PlayRateBasis_Value", "({PinFriendlyName} / {PlayRateBasis})"), Args);
|
|
}
|
|
}
|
|
else // PlayRateBasisPin is visible
|
|
{
|
|
FFormatNamedArguments Args;
|
|
Args.Add(TEXT("PinFriendlyName"), Pin->PinFriendlyName);
|
|
Pin->PinFriendlyName = FText::Format(LOCTEXT("FAnimNode_SequencePlayer_PlayRateBasis_Name", "({PinFriendlyName} / PlayRateBasis)"), Args);
|
|
}
|
|
|
|
Pin->PinFriendlyName = Node.GetPlayRateScaleBiasClampConstants().GetFriendlyName(Pin->PinFriendlyName);
|
|
}
|
|
}
|
|
}
|
|
|
|
void UAnimGraphNode_SequencePlayer::PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent)
|
|
{
|
|
const FName PropertyName = (PropertyChangedEvent.Property ? PropertyChangedEvent.Property->GetFName() : NAME_None);
|
|
|
|
// Reconstruct node to show updates to PinFriendlyNames.
|
|
if ((PropertyName == GET_MEMBER_NAME_STRING_CHECKED(FAnimNode_SequencePlayer, PlayRateBasis))
|
|
|| (PropertyName == GET_MEMBER_NAME_STRING_CHECKED(FInputScaleBiasClampConstants, bMapRange))
|
|
|| (PropertyName == GET_MEMBER_NAME_STRING_CHECKED(FInputRange, Min))
|
|
|| (PropertyName == GET_MEMBER_NAME_STRING_CHECKED(FInputRange, Max))
|
|
|| (PropertyName == GET_MEMBER_NAME_STRING_CHECKED(FInputScaleBiasClampConstants, Scale))
|
|
|| (PropertyName == GET_MEMBER_NAME_STRING_CHECKED(FInputScaleBiasClampConstants, Bias))
|
|
|| (PropertyName == GET_MEMBER_NAME_STRING_CHECKED(FInputScaleBiasClampConstants, bClampResult))
|
|
|| (PropertyName == GET_MEMBER_NAME_STRING_CHECKED(FInputScaleBiasClampConstants, ClampMin))
|
|
|| (PropertyName == GET_MEMBER_NAME_STRING_CHECKED(FInputScaleBiasClampConstants, ClampMax))
|
|
|| (PropertyName == GET_MEMBER_NAME_STRING_CHECKED(FInputScaleBiasClampConstants, bInterpResult))
|
|
|| (PropertyName == GET_MEMBER_NAME_STRING_CHECKED(FInputScaleBiasClampConstants, InterpSpeedIncreasing))
|
|
|| (PropertyName == GET_MEMBER_NAME_STRING_CHECKED(FInputScaleBiasClampConstants, InterpSpeedDecreasing)))
|
|
{
|
|
ReconstructNode();
|
|
}
|
|
|
|
Super::PostEditChangeProperty(PropertyChangedEvent);
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE
|