2020-09-01 14:07:48 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
|
#include "KismetCompiler.h"
|
|
|
|
|
#include "Animation/AnimNodeBase.h"
|
|
|
|
|
#include "AnimGraphNode_Base.h"
|
|
|
|
|
#include "KismetCompilerModule.h"
|
2020-09-09 08:32:25 -04:00
|
|
|
#include "IAnimBlueprintCompilerCreationContext.h"
|
2021-01-06 09:11:59 -04:00
|
|
|
#include "Containers/ArrayView.h"
|
2021-04-22 04:57:09 -04:00
|
|
|
#include "IAnimBlueprintCompilationContext.h"
|
2020-09-01 14:07:48 -04:00
|
|
|
|
|
|
|
|
class UAnimationGraphSchema;
|
|
|
|
|
class UAnimGraphNode_SaveCachedPose;
|
|
|
|
|
class UAnimGraphNode_StateMachineBase;
|
|
|
|
|
class UAnimGraphNode_StateResult;
|
|
|
|
|
class UAnimGraphNode_CustomProperty;
|
|
|
|
|
|
|
|
|
|
class UAnimGraphNode_UseCachedPose;
|
|
|
|
|
class UAnimStateTransitionNode;
|
|
|
|
|
class UK2Node_CallFunction;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Forward declarations.
|
|
|
|
|
//
|
|
|
|
|
class UAnimGraphNode_SaveCachedPose;
|
|
|
|
|
class UAnimGraphNode_UseCachedPose;
|
|
|
|
|
class UAnimGraphNode_LinkedInputPose;
|
|
|
|
|
class UAnimGraphNode_LinkedAnimGraphBase;
|
|
|
|
|
class UAnimGraphNode_LinkedAnimGraph;
|
|
|
|
|
class UAnimGraphNode_Root;
|
|
|
|
|
|
|
|
|
|
class FStructProperty;
|
|
|
|
|
class UBlueprintGeneratedClass;
|
|
|
|
|
struct FPoseLinkMappingRecord;
|
|
|
|
|
struct FAnimGraphNodePropertyBinding;
|
|
|
|
|
class FAnimBlueprintCompilerContext;
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// FAnimBlueprintCompilerContext
|
|
|
|
|
class FAnimBlueprintCompilerContext : public FKismetCompilerContext
|
|
|
|
|
{
|
2020-09-09 08:32:25 -04:00
|
|
|
friend class FAnimBlueprintCompilerCreationContext;
|
|
|
|
|
friend class FAnimBlueprintCompilationContext;
|
|
|
|
|
friend class FAnimBlueprintVariableCreationContext;
|
|
|
|
|
friend class FAnimBlueprintCompilationBracketContext;
|
|
|
|
|
friend class FAnimBlueprintPostExpansionStepContext;
|
|
|
|
|
friend class FAnimBlueprintCopyTermDefaultsContext;
|
2021-09-09 11:42:21 -04:00
|
|
|
friend class UK2Node_AnimNodeReference;
|
2020-09-01 14:07:48 -04:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
typedef FKismetCompilerContext Super;
|
|
|
|
|
public:
|
|
|
|
|
FAnimBlueprintCompilerContext(UAnimBlueprint* SourceSketch, FCompilerResultsLog& InMessageLog, const FKismetCompilerOptions& InCompileOptions);
|
|
|
|
|
virtual ~FAnimBlueprintCompilerContext();
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
// Implementation of FKismetCompilerContext interface
|
|
|
|
|
virtual void CreateClassVariablesFromBlueprint() override;
|
|
|
|
|
virtual UEdGraphSchema_K2* CreateSchema() override;
|
|
|
|
|
virtual void MergeUbergraphPagesIn(UEdGraph* Ubergraph) override;
|
|
|
|
|
virtual void ProcessOneFunctionGraph(UEdGraph* SourceGraph, bool bInternalFunction = false) override;
|
|
|
|
|
virtual void SpawnNewClass(const FString& NewClassName) override;
|
|
|
|
|
virtual void OnNewClassSet(UBlueprintGeneratedClass* ClassToUse) override;
|
2022-02-21 02:04:58 -05:00
|
|
|
virtual void OnPostCDOCompiled(const UObject::FPostCDOCompiledContext& Context) override;
|
2020-09-01 14:07:48 -04:00
|
|
|
virtual void CopyTermDefaultsToDefaultObject(UObject* DefaultObject) override;
|
2020-09-09 08:32:25 -04:00
|
|
|
virtual void PostCompile() override;
|
2020-09-01 14:07:48 -04:00
|
|
|
virtual void PostCompileDiagnostics() override;
|
|
|
|
|
virtual void EnsureProperGeneratedClass(UClass*& TargetClass) override;
|
|
|
|
|
virtual void CleanAndSanitizeClass(UBlueprintGeneratedClass* ClassToClean, UObject*& InOldCDO) override;
|
|
|
|
|
virtual void FinishCompilingClass(UClass* Class) override;
|
|
|
|
|
virtual void PrecompileFunction(FKismetFunctionContext& Context, EInternalCompilerFlags InternalFlags) override;
|
|
|
|
|
virtual void SetCalculatedMetaDataAndFlags(UFunction* Function, UK2Node_FunctionEntry* EntryNode, const UEdGraphSchema_K2* Schema ) override;
|
|
|
|
|
virtual bool ShouldForceKeepNode(const UEdGraphNode* Node) const override;
|
2020-09-09 08:32:25 -04:00
|
|
|
virtual void PostExpansionStep(const UEdGraph* Graph) override;
|
Merging //UE5/Dev-LargeWorldCoordinates [at] 18802167 to //UE5/Release-5.0
Blueprint real number support.
This change deprecates the use the of "float" and "double" types in Blueprints in favor of a new "real". By default, "real" is back by a double precision floating point number. However, it can be single precision if the number is a native float property or function parameter. This distinction won't be visible to the Blueprint user: in both instances, they'll be represented by "real" pin types. During deserialization, we'll automatically convert Blueprint pin types to use real/doubles, unless they're used to represent native code (including delegate signatures).
One consequence of this change is that we need to perform implicit casts between single and double precision real numbers. During Blueprint compilation, the compiler will detect points in the graph for when either a widening or narrowing conversion needs to occur. Subsequently, the script bytecode will contain a new cast instruction that performs the conversion. This also works on container types, but each entry in the container will have to be converted. This can introduce unwanted overhead for large containers that are frequently passed between Blueprint and native code.
The scope of this change affects Blueprints used by Gameplay, Animation, Control Rig, and UMG.
#rb marc.audy (serialization changes)
#jira UE-116484
#preflight 61f8bdd5a2514ba12ff7bdfc
#ROBOMERGE-AUTHOR: dave.jones2
#ROBOMERGE-SOURCE: CL 18809077 in //UE5/Release-5.0/... via CL 18809455 via CL 18822548
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v908-18788545)
[CL 18823569 by dave jones2 in ue5-main branch]
2022-02-02 05:50:50 -05:00
|
|
|
virtual void PreCompileUpdateBlueprintOnLoad(UBlueprint* BP) override;
|
2020-09-01 14:07:48 -04:00
|
|
|
// End of FKismetCompilerContext interface
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
typedef TArray<UEdGraphPin*> UEdGraphPinArray;
|
|
|
|
|
|
|
|
|
|
protected:
|
2021-04-22 04:57:09 -04:00
|
|
|
UScriptStruct* NewAnimBlueprintConstants;
|
|
|
|
|
UScriptStruct* NewAnimBlueprintMutables;
|
|
|
|
|
FStructProperty* NewMutablesProperty;
|
2020-09-01 14:07:48 -04:00
|
|
|
UAnimBlueprint* AnimBlueprint;
|
|
|
|
|
|
2021-12-07 05:32:13 -05:00
|
|
|
// Old sparse class data stored to patchup linker when doing a full compile
|
|
|
|
|
UScriptStruct* OldSparseClassDataStruct;
|
|
|
|
|
|
2020-09-01 14:07:48 -04:00
|
|
|
UAnimationGraphSchema* AnimSchema;
|
|
|
|
|
|
|
|
|
|
// Map of allocated v3 nodes that are members of the class
|
|
|
|
|
TMap<class UAnimGraphNode_Base*, FProperty*> AllocatedAnimNodes;
|
2023-07-19 04:36:34 -04:00
|
|
|
TMap<class UAnimGraphNode_Base*, FProperty*> AllocatedAnimNodeHandlers;
|
2020-09-01 14:07:48 -04:00
|
|
|
TMap<FProperty*, class UAnimGraphNode_Base*> AllocatedNodePropertiesToNodes;
|
2021-04-22 04:57:09 -04:00
|
|
|
TMap<FProperty*, class UAnimGraphNode_Base*> AllocatedNodeConstantPropertiesToNodes;
|
2020-09-01 14:07:48 -04:00
|
|
|
TMap<int32, FProperty*> AllocatedPropertiesByIndex;
|
|
|
|
|
|
|
|
|
|
// Map of true source objects (user edited ones) to the cloned ones that are actually compiled
|
|
|
|
|
TMap<class UAnimGraphNode_Base*, UAnimGraphNode_Base*> SourceNodeToProcessedNodeMap;
|
|
|
|
|
|
|
|
|
|
// Index of the nodes (must match up with the runtime discovery process of nodes, which runs thru the property chain)
|
|
|
|
|
int32 AllocateNodeIndexCounter;
|
|
|
|
|
TMap<class UAnimGraphNode_Base*, int32> AllocatedAnimNodeIndices;
|
|
|
|
|
|
|
|
|
|
// Map from pose link LinkID address
|
|
|
|
|
//@TODO: Bad structure for a list of these
|
|
|
|
|
TArray<FPoseLinkMappingRecord> ValidPoseLinkList;
|
|
|
|
|
|
|
|
|
|
// Stub graphs we generated for animation graph functions
|
|
|
|
|
TArray<UEdGraph*> GeneratedStubGraphs;
|
|
|
|
|
|
|
|
|
|
// True if any parent class is also generated from an animation blueprint
|
|
|
|
|
bool bIsDerivedAnimBlueprint;
|
|
|
|
|
|
2020-09-09 08:32:25 -04:00
|
|
|
// Graph schema classes that this compiler is aware of - they will skip default function processing
|
|
|
|
|
TArray<TSubclassOf<UEdGraphSchema>> KnownGraphSchemas;
|
|
|
|
|
|
|
|
|
|
// Expose compile options to handlers
|
2020-09-01 14:07:48 -04:00
|
|
|
using FKismetCompilerContext::CompileOptions;
|
|
|
|
|
|
2021-04-22 04:57:09 -04:00
|
|
|
// Records of folded properties gleaned from nodes
|
|
|
|
|
TArray<TSharedRef<IAnimBlueprintCompilationContext::FFoldedPropertyRecord>> ConstantPropertyRecords;
|
|
|
|
|
TArray<TSharedRef<IAnimBlueprintCompilationContext::FFoldedPropertyRecord>> MutablePropertyRecords;
|
|
|
|
|
|
|
|
|
|
// Allows lookups to see if a node participates in constant folding
|
|
|
|
|
TMap<UAnimGraphNode_Base*, TArray<TSharedRef<IAnimBlueprintCompilationContext::FFoldedPropertyRecord>>> NodeToFoldedPropertyRecordMap;
|
|
|
|
|
|
|
|
|
|
// Maps of extension <-> generated property on the instance
|
|
|
|
|
TMap<UAnimBlueprintExtension*, FStructProperty*> ExtensionToInstancePropertyMap;
|
|
|
|
|
TMap<FStructProperty*, UAnimBlueprintExtension*> InstancePropertyToExtensionMap;
|
|
|
|
|
|
|
|
|
|
// Maps of extension <-> generated property on the class
|
|
|
|
|
TMap<UAnimBlueprintExtension*, FStructProperty*> ExtensionToClassPropertyMap;
|
|
|
|
|
TMap<FStructProperty*, UAnimBlueprintExtension*> ClassPropertyToExtensionMap;
|
|
|
|
|
|
2020-09-01 14:07:48 -04:00
|
|
|
private:
|
2021-04-22 04:57:09 -04:00
|
|
|
// Get the generated class as an anim blueprint generated class
|
|
|
|
|
UAnimBlueprintGeneratedClass* GetNewAnimBlueprintClass() const { return CastChecked<UAnimBlueprintGeneratedClass>(NewClass); };
|
|
|
|
|
|
2020-09-01 14:07:48 -04:00
|
|
|
// Run a function on the passed-in graph and each subgraph of it
|
|
|
|
|
void ForAllSubGraphs(UEdGraph* InGraph, TFunctionRef<void(UEdGraph*)> InPerGraphFunction);
|
|
|
|
|
|
|
|
|
|
// Prunes any nodes that aren't reachable via a pose link
|
|
|
|
|
void PruneIsolatedAnimationNodes(const TArray<UAnimGraphNode_Base*>& RootSet, TArray<UAnimGraphNode_Base*>& GraphNodes);
|
|
|
|
|
|
|
|
|
|
// Compiles one animation node
|
|
|
|
|
void ProcessAnimationNode(UAnimGraphNode_Base* VisualAnimNode);
|
|
|
|
|
|
2021-04-22 04:57:09 -04:00
|
|
|
// Called during ProcessAnimationNode - gather property folding records for the node
|
|
|
|
|
void GatherFoldRecordsForAnimationNode(const UScriptStruct* InNodeType, FStructProperty* InNodeProperty, UAnimGraphNode_Base* InVisualAnimNode);
|
2020-09-01 14:07:48 -04:00
|
|
|
|
|
|
|
|
// Compiles an entire animation graph
|
|
|
|
|
void ProcessAllAnimationNodes();
|
|
|
|
|
|
|
|
|
|
// Processes all the supplied anim nodes
|
|
|
|
|
void ProcessAnimationNodes(TArray<UAnimGraphNode_Base*>& AnimNodeList);
|
|
|
|
|
|
2021-04-22 04:57:09 -04:00
|
|
|
// Process all the requested extensions
|
|
|
|
|
void ProcessExtensions();
|
|
|
|
|
|
2020-09-01 14:07:48 -04:00
|
|
|
// Gets all anim graph nodes that are piped into the provided node (traverses input pins)
|
2020-09-09 08:32:25 -04:00
|
|
|
void GetLinkedAnimNodes(UAnimGraphNode_Base* InGraphNode, TArray<UAnimGraphNode_Base*>& LinkedAnimNodes) const;
|
|
|
|
|
void GetLinkedAnimNodes_TraversePin(UEdGraphPin* InPin, TArray<UAnimGraphNode_Base*>& LinkedAnimNodes) const;
|
|
|
|
|
void GetLinkedAnimNodes_ProcessAnimNode(UAnimGraphNode_Base* AnimNode, TArray<UAnimGraphNode_Base*>& LinkedAnimNodes) const;
|
2020-09-01 14:07:48 -04:00
|
|
|
|
|
|
|
|
// Returns the allocation index of the specified node, processing it if it was pending
|
|
|
|
|
int32 GetAllocationIndexOfNode(UAnimGraphNode_Base* VisualAnimNode);
|
|
|
|
|
|
|
|
|
|
// Create transient stub functions for each anim graph we are compiling
|
|
|
|
|
void CreateAnimGraphStubFunctions();
|
|
|
|
|
|
|
|
|
|
// Clean up transient stub functions
|
|
|
|
|
void DestroyAnimGraphStubFunctions();
|
|
|
|
|
|
|
|
|
|
// Expands split pins for a graph
|
|
|
|
|
void ExpandSplitPins(UEdGraph* InGraph);
|
2021-01-06 09:11:59 -04:00
|
|
|
|
|
|
|
|
// Add the specified compiled-in attribute uniquely to the specified node
|
|
|
|
|
void AddAttributesToNode(UAnimGraphNode_Base* InNode, TArrayView<const FName> InAttributes) const;
|
|
|
|
|
|
|
|
|
|
// Get the current compiled-in attributes uniquely assigned to the specified node
|
|
|
|
|
TArrayView<const FName> GetAttributesFromNode(UAnimGraphNode_Base* InNode) const;
|
2021-04-22 04:57:09 -04:00
|
|
|
|
|
|
|
|
// Called at the start of compilation to (re-) create the mutable struct
|
|
|
|
|
void RecreateMutables();
|
|
|
|
|
|
|
|
|
|
// (Re-)creates sparse class data structure. Called at the start of compilation to (re-) create the internal sparse
|
|
|
|
|
// class data. For derived anim BPs this is called just-in-time before CDO copy. This is to ensure that the sparse
|
|
|
|
|
// class data is always updated, as in some cases as the layout does not change a full compilation of a (data-only)
|
|
|
|
|
// derived anim BP may be skipped.
|
|
|
|
|
void RecreateSparseClassData();
|
2021-02-15 10:47:36 -04:00
|
|
|
|
|
|
|
|
// Create a uniquely named variable corresponding to an object in the current class
|
|
|
|
|
FProperty* CreateUniqueVariable(UObject* InForObject, const FEdGraphPinType& Type);
|
2021-04-22 04:57:09 -04:00
|
|
|
|
|
|
|
|
/** Creates a variable on the specified struct */
|
|
|
|
|
FProperty* CreateStructVariable(UScriptStruct* InStruct, const FName VarName, const FEdGraphPinType& VarType);
|
|
|
|
|
|
|
|
|
|
/** Adds a record for a potentially-folded anim node property */
|
2021-06-17 08:59:23 -04:00
|
|
|
void AddFoldedPropertyRecord(UAnimGraphNode_Base* InAnimGraphNode, FStructProperty* InAnimNodeProperty, FProperty* InProperty, bool bInExposedOnPin, bool bInPinConnected, bool bInAlwaysDynamic);
|
2021-04-22 04:57:09 -04:00
|
|
|
|
|
|
|
|
/** Process any anim node properties that are 'foldable' */
|
|
|
|
|
void ProcessFoldedPropertyRecords();
|
|
|
|
|
|
|
|
|
|
// Check whether an anim node participates in constant folding
|
|
|
|
|
bool IsAnimGraphNodeFolded(UAnimGraphNode_Base* InNode) const;
|
|
|
|
|
|
2021-05-13 10:57:08 -04:00
|
|
|
// Copy the AnimNodeData array etc. from root anim BP class to a derived anim BP
|
|
|
|
|
void CopyAnimNodeDataFromRoot() const;
|
|
|
|
|
|
2021-04-22 04:57:09 -04:00
|
|
|
// Get the folded property record, if any, for the supplied node & named property
|
|
|
|
|
const IAnimBlueprintCompilationContext::FFoldedPropertyRecord* GetFoldedPropertyRecord(UAnimGraphNode_Base* InNode, FName InPropertyName) const;
|
2020-09-01 14:07:48 -04:00
|
|
|
};
|
|
|
|
|
|