You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Adds 'template' anim BP concept. These anim BPs have no TargetSkeleton and as such cannot have direct references to animations placed inside of their anim graphs Adds function call support from anim nodes. All anim graph nodes can now call functions when initialized, updated, evaluated or when they first become relevant. Relevancy is established using a new FAnimSubsystemInstance_NodeRelevancy which tracks nodes in a local map, per UAnimInstance, if nodes require it. Functions are displayed on the node if bound, and in the details panel. Added a new override point to FAnimSubsystemInstance to allow for WT init. Moved FMemberReference customization into a public header so it can be used on anim node functions. Wrapped functions up into FAnimNodeFunctionRef structure so they can be re-used more effectively. Converted CallFunction node to use them. Added a couple of simple BP function libraries to demonstrate the use of the new FAnimNodeContext (this is intended to be a generic way of exposing FAnimNode_Base types to script without the node types themselves having to be known to script directly). Added the ability to set exposed properties as 'always dynamic' so they appear in mutable data rather than being merged into constants. This allows for the anim node data API to be changed to be less strict (and more script friendly). Now values can be set in mutable data (via GET_MUTABLE_ANIM_NODE_DATA_PTR) and attempted sets to constant data can be ignored and reported to client code. A few minor crash fixes with edge cases (inc when trying to open an asset editor fails because of a missing skeleton/cancellation). Also fixes an issue where literal linked anim graph/control rig/custom poroperty node inputs didnt get copied #rb Jurre.deBaare,Aaron.Cox #ROBOMERGE-SOURCE: CL 16703644 in //UE5/Main/... #ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v835-16672529) [CL 16703653 by thomas sarkanen in ue5-release-engine-test branch]
315 lines
11 KiB
C++
315 lines
11 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 "UAnimGraphNode_SequencePlayer"
|
|
|
|
/////////////////////////////////////////////////////
|
|
// 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);
|
|
}
|
|
}
|
|
|
|
FSlateIcon UAnimGraphNode_SequencePlayer::GetIconAndTint(FLinearColor& OutColor) const
|
|
{
|
|
return FSlateIcon("EditorStyle", "ClassIcon.AnimSequence");
|
|
}
|
|
|
|
FText UAnimGraphNode_SequencePlayer::GetNodeTitle(ENodeTitleType::Type TitleType) const
|
|
{
|
|
UEdGraphPin* SequencePin = FindPin(GET_MEMBER_NAME_STRING_CHECKED(FAnimNode_SequencePlayer, Sequence));
|
|
return GetNodeTitleHelper(TitleType, SequencePin, LOCTEXT("PlayerDesc", "Sequence Player"),
|
|
[](UAnimationAsset* InAsset)
|
|
{
|
|
UAnimSequenceBase* SequenceBase = CastChecked<UAnimSequenceBase>(InAsset);
|
|
const bool bAdditive = SequenceBase->IsValidAdditive();
|
|
return bAdditive ? LOCTEXT("AdditivePostFix", "(additive)") : FText::GetEmpty();
|
|
});
|
|
}
|
|
|
|
FText UAnimGraphNode_SequencePlayer::GetMenuCategory() const
|
|
{
|
|
return FEditorCategoryUtils::GetCommonCategory(FCommonEditorCategory::Animation);
|
|
}
|
|
|
|
void UAnimGraphNode_SequencePlayer::GetMenuActions(FBlueprintActionDatabaseRegistrar& InActionRegistrar) const
|
|
{
|
|
GetMenuActionsHelper(
|
|
InActionRegistrar,
|
|
GetClass(),
|
|
{ UAnimSequence::StaticClass() },
|
|
{ },
|
|
[](const FAssetData& InAssetData)
|
|
{
|
|
if(InAssetData.IsValid())
|
|
{
|
|
const FString TagValue = InAssetData.GetTagValueRef<FString>(GET_MEMBER_NAME_CHECKED(UAnimSequence, AdditiveAnimType));
|
|
if(const bool bKnownToBeAdditive = (!TagValue.IsEmpty() && !TagValue.Equals(TEXT("AAT_None"))))
|
|
{
|
|
return FText::Format(LOCTEXT("MenuDescFormat", "Play '{0}' (additive)"), FText::FromName(InAssetData.AssetName));
|
|
}
|
|
else
|
|
{
|
|
return FText::Format(LOCTEXT("MenuDescFormat", "Play '{0}'"), FText::FromName(InAssetData.AssetName));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return LOCTEXT("PlayerDesc", "Sequence Player");
|
|
}
|
|
},
|
|
[](const FAssetData& InAssetData)
|
|
{
|
|
if(InAssetData.IsValid())
|
|
{
|
|
const FString TagValue = InAssetData.GetTagValueRef<FString>(GET_MEMBER_NAME_CHECKED(UAnimSequence, AdditiveAnimType));
|
|
if(const bool bKnownToBeAdditive = (!TagValue.IsEmpty() && !TagValue.Equals(TEXT("AAT_None"))))
|
|
{
|
|
return FText::Format(LOCTEXT("MenuDescTooltipFormat", "Play (additive)\n'{0}'"), FText::FromName(InAssetData.ObjectPath));
|
|
}
|
|
else
|
|
{
|
|
return FText::Format(LOCTEXT("MenuDescTooltipFormat", "Play\n'{0}'"), FText::FromName(InAssetData.ObjectPath));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return LOCTEXT("PlayerDescTooltip", "Sequence Player");
|
|
}
|
|
},
|
|
[](UEdGraphNode* InNewNode, bool bInIsTemplateNode, const FAssetData InAssetData)
|
|
{
|
|
UAnimGraphNode_AssetPlayerBase::SetupNewNode(InNewNode, bInIsTemplateNode, InAssetData);
|
|
});
|
|
}
|
|
|
|
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);
|
|
|
|
ValidateAnimNodeDuringCompilationHelper(ForSkeleton, MessageLog, Node.GetSequence(), UAnimSequenceBase::StaticClass(), FindPin(GET_MEMBER_NAME_STRING_CHECKED(FAnimNode_SequencePlayer, Sequence)));
|
|
}
|
|
|
|
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", LOCTEXT("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
|