Files

76 lines
2.9 KiB
C
Raw Permalink Normal View History

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "AnimGraphNode_Base.h"
#include "AnimNodes/AnimNode_CallFunction.h"
#include "Engine/MemberReference.h"
#include "AnimGraphNode_CallFunction.generated.h"
class UEdGraph;
class UK2Node_CallFunction;
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
UCLASS(MinimalAPI, Experimental, meta=(Keywords = "Event"))
class UAnimGraphNode_CallFunction : public UAnimGraphNode_Base
{
GENERATED_BODY()
private:
// Inner graph we maintain to hook into the function call machinery
UPROPERTY()
TObjectPtr<UEdGraph> InnerGraph;
// Inner node we maintain to hook into the function call machinery
UPROPERTY()
TObjectPtr<UK2Node_CallFunction> CallFunctionPrototype;
UPROPERTY(EditAnywhere, Category=Settings)
FAnimNode_CallFunction Node;
// Delegate handles used to hook into inner graph & function nodes
FDelegateHandle GraphChangedHandle;
FDelegateHandle PinRenamedHandle;
// UObject interface
virtual void PostLoad() override;
// UEdGraphNode interface
virtual FLinearColor GetNodeTitleColor() const override;
virtual FText GetNodeTitle(ENodeTitleType::Type TitleType) const override;
virtual FText GetTooltipText() const override;
virtual void AllocateDefaultPins() override;
virtual void ReallocatePinsDuringReconstruction(TArray<UEdGraphPin*>& InOldPins) override;
virtual UObject* GetJumpTargetForDoubleClick() const override;
virtual void JumpToDefinition() const override;
virtual void ValidateNodeDuringCompilation(FCompilerResultsLog& MessageLog) const override;
// UK2Node interface
virtual FText GetMenuCategory() const override;
virtual void ExpandNode(FKismetCompilerContext& CompilerContext, UEdGraph* SourceGraph) override;
virtual void GetMenuActions(FBlueprintActionDatabaseRegistrar& ActionRegistrar) const override;
virtual bool IsActionFilteredOut(class FBlueprintActionFilter const& Filter) override;
// UAnimGraphNode_Base interface
virtual void GetRequiredExtensions(TArray<TSubclassOf<UAnimBlueprintExtension>>& OutExtensions) const override;
virtual bool ShouldCreateStructEvalHandlers() const override { return false; }
virtual void OnProcessDuringCompilation(IAnimBlueprintCompilationContext& InCompilationContext, IAnimBlueprintGeneratedClassCompiledData& OutCompiledData) override;
private:
void AllocateFunctionPins();
/** Sets up node internals */
void SetupFromFunction(UFunction* InFunction);
void BindDelegates();
/** Checks to see if the passed-in function is disallowed in anim graphs. */
bool IsFunctionDenied(const UFunction* InFunction) const;
/** Validate the function's parameters to check if it can be called in anim graphs */
bool AreFunctionParamsValid(const UFunction* InFunction) const;
/** Validates a function. Used for populating menu actions and verifying already-referenced functions */
bool ValidateFunction(const UFunction* InFunction, FCompilerResultsLog* InMessageLog = nullptr) const;
};