Files
UnrealEngineUWP/Engine/Source/Runtime/AnimGraphRuntime/Public/AnimNodes/AnimNode_CallFunction.h
thomas sarkanen cecebd0cf8 Anim blueprint encapsulation improvements
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]
2021-06-17 08:59:23 -04:00

93 lines
3.7 KiB
C

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Animation/AnimNodeBase.h"
#include "Animation/AnimNodeFunctionRef.h"
#include "AnimNode_CallFunction.generated.h"
// When to call the function during the execution of the animation graph
UENUM()
enum class EAnimFunctionCallSite
{
// Called when the node is initialized - i.e. it becomes weighted/relevant in the graph (before child nodes are initialized)
OnInitialize,
// Called when the node is updated (before child nodes are updated)
OnUpdate,
// Called when the node is updated for the first time with a valid weight
OnBecomeRelevant,
// Called when the node is evaluated (before child nodes are evaluated)
OnEvaluate,
// Called when the node is initialized - i.e. it becomes weighted/relevant in the graph (after child nodes are initialized)
OnInitializePostRecursion UMETA(DisplayName = "On Initialize (Post Recursion)"),
// Called when the node is updated (after child nodes are updated)
OnUpdatePostRecursion UMETA(DisplayName = "On Update (Post Recursion)"),
// Called when the node is updated for the first time with a valid weight (after child nodes are updated)
OnBecomeRelevantPostRecursion UMETA(DisplayName = "On Become Relevant (Post Recursion)"),
// Called when the node is evaluated (after child nodes are evaluated)
OnEvaluatePostRecursion UMETA(DisplayName = "On Evaluate (Post Recursion)"),
// Called when the node is updated, was at full weight and beings to blend out. Called before child nodes are
// updated
OnStartedBlendingOut,
// Called when the node is updated, was at zero weight and beings to blend in. Called before child nodes are updated
OnStartedBlendingIn,
// Called when the node is updated, was at non-zero weight and finishes blending out. Called before child nodes are
// updated (note that this is necessarily not called within the graph update but from outside)
// @TODO: Not currently supported, needs subsystem support!
OnFinishedBlendingOut UMETA(Hidden),
// Called when the node is updated, was at non-zero weight and becomes full weight. Called before child nodes are
// updated
OnFinishedBlendingIn,
};
/** Calls specified user-defined events/functions during anim graph execution */
USTRUCT(BlueprintInternalUseOnly)
struct ANIMGRAPHRUNTIME_API FAnimNode_CallFunction : public FAnimNode_Base
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, Category = Links)
FPoseLink Source;
#if WITH_EDITORONLY_DATA
// Function to call
UPROPERTY(meta=(FoldProperty))
FAnimNodeFunctionRef Function;
#endif
// Counter used to determine relevancy
FGraphTraversalCounter Counter;
// Weight to determine blend-related call sites
float CurrentWeight = 0.0f;
// When to call the function during the execution of the animation graph
UPROPERTY(EditAnywhere, Category="Function")
EAnimFunctionCallSite CallSite = EAnimFunctionCallSite::OnUpdate;
// FAnimNode_Base interface
virtual void OnInitializeAnimInstance(const FAnimInstanceProxy* InProxy, const UAnimInstance* InAnimInstance) override;
virtual bool NeedsOnInitializeAnimInstance() const override { return true; }
virtual void GatherDebugData(FNodeDebugData& DebugData) override;
virtual void Update_AnyThread(const FAnimationUpdateContext& Context) override;
virtual void Evaluate_AnyThread(FPoseContext& Context) override;
virtual void Initialize_AnyThread(const FAnimationInitializeContext& Context) override;
// End of FAnimNode_Base interface
// Calls the function we hold if the callsite matches the one we have set
void CallFunctionFromCallSite(EAnimFunctionCallSite InCallSite, const FAnimationBaseContext& InContext) const;
// Get the function held on this node
const FAnimNodeFunctionRef& GetFunction() const;
};