2014-12-07 19:09:38 -05:00
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
2014-03-14 14:13:41 -04:00
# pragma once
2015-06-17 15:27:23 -04:00
2014-04-24 08:49:31 -04:00
# include "K2Node.h"
2014-05-29 17:24:15 -04:00
# include "Animation/AnimNodeBase.h"
2014-03-14 14:13:41 -04:00
# include "AnimGraphNode_Base.generated.h"
2015-06-17 15:27:23 -04:00
// Forward declarations
2014-03-14 14:13:41 -04:00
2015-06-17 15:27:23 -04:00
struct FEdGraphSchemaAction_K2NewNode ;
struct FPropertyChangedEvent ;
class FCompilerResultsLog ;
class UAnimGraphNode_Base ;
class USkeleton ;
class UAnimBlueprintGeneratedClass ;
class IDetailLayoutBuilder ;
class FAnimBlueprintCompiler ;
class FAnimGraphNodeDetails ;
//
2014-03-14 14:13:41 -04:00
struct FPoseLinkMappingRecord
{
public :
2015-06-17 15:27:23 -04:00
static FPoseLinkMappingRecord MakeFromArrayEntry ( UAnimGraphNode_Base * LinkingNode , UAnimGraphNode_Base * LinkedNode , UArrayProperty * ArrayProperty , int32 ArrayIndex )
2014-03-14 14:13:41 -04:00
{
checkSlow ( CastChecked < UStructProperty > ( ArrayProperty - > Inner ) - > Struct - > IsChildOf ( FPoseLinkBase : : StaticStruct ( ) ) ) ;
FPoseLinkMappingRecord Result ;
Result . LinkingNode = LinkingNode ;
Result . LinkedNode = LinkedNode ;
Result . ChildProperty = ArrayProperty ;
Result . ChildPropertyIndex = ArrayIndex ;
return Result ;
}
2015-06-17 15:27:23 -04:00
static FPoseLinkMappingRecord MakeFromMember ( UAnimGraphNode_Base * LinkingNode , UAnimGraphNode_Base * LinkedNode , UStructProperty * MemberProperty )
2014-03-14 14:13:41 -04:00
{
checkSlow ( MemberProperty - > Struct - > IsChildOf ( FPoseLinkBase : : StaticStruct ( ) ) ) ;
FPoseLinkMappingRecord Result ;
Result . LinkingNode = LinkingNode ;
Result . LinkedNode = LinkedNode ;
Result . ChildProperty = MemberProperty ;
Result . ChildPropertyIndex = INDEX_NONE ;
return Result ;
}
static FPoseLinkMappingRecord MakeInvalid ( )
{
FPoseLinkMappingRecord Result ;
return Result ;
}
bool IsValid ( ) const
{
2015-06-17 15:27:23 -04:00
return LinkedNode ! = nullptr ;
2014-03-14 14:13:41 -04:00
}
2015-06-17 15:27:23 -04:00
UAnimGraphNode_Base * GetLinkedNode ( ) const
2014-03-14 14:13:41 -04:00
{
return LinkedNode ;
}
2015-06-17 15:27:23 -04:00
UAnimGraphNode_Base * GetLinkingNode ( ) const
2014-03-14 14:13:41 -04:00
{
return LinkingNode ;
}
ANIMGRAPH_API void PatchLinkIndex ( uint8 * DestinationPtr , int32 LinkID , int32 SourceLinkID ) const ;
protected :
FPoseLinkMappingRecord ( )
2015-06-17 15:27:23 -04:00
: LinkedNode ( nullptr )
, LinkingNode ( nullptr )
, ChildProperty ( nullptr )
2014-03-14 14:13:41 -04:00
, ChildPropertyIndex ( INDEX_NONE )
{
}
protected :
2015-06-17 15:27:23 -04:00
// Linked node for this pose link, can be nullptr
UAnimGraphNode_Base * LinkedNode ;
2014-03-14 14:13:41 -04:00
2015-06-17 15:27:23 -04:00
// Linking node for this pose link, can be nullptr
UAnimGraphNode_Base * LinkingNode ;
2014-03-14 14:13:41 -04:00
// Will either be an array property containing FPoseLinkBase derived structs, indexed by ChildPropertyIndex, or a FPoseLinkBase derived struct property
UProperty * ChildProperty ;
// Index when ChildProperty is an array
int32 ChildPropertyIndex ;
} ;
2015-06-17 15:27:23 -04:00
/**
* This is the base class for any animation graph nodes that generate or consume an animation pose in
* the animation blend graph .
*
* Any concrete implementations will be paired with a runtime graph node derived from FAnimNode_Base
*/
UCLASS ( Abstract )
class ANIMGRAPH_API UAnimGraphNode_Base : public UK2Node
2014-03-14 14:13:41 -04:00
{
2015-03-17 05:38:32 -04:00
GENERATED_UCLASS_BODY ( )
2014-03-14 14:13:41 -04:00
UPROPERTY ( EditAnywhere , BlueprintReadWrite , Category = PinOptions , EditFixedSize )
TArray < FOptionalPinFromProperty > ShowPinForProperties ;
// UObject interface
2015-06-17 15:27:23 -04:00
virtual void PostEditChangeProperty ( FPropertyChangedEvent & PropertyChangedEvent ) override ;
2014-03-14 14:13:41 -04:00
// End of UObject interface
// UEdGraphNode interface
2015-06-17 15:27:23 -04:00
virtual void AllocateDefaultPins ( ) override ;
virtual FLinearColor GetNodeTitleColor ( ) const override ;
virtual FString GetDocumentationLink ( ) const override ;
virtual void GetPinHoverText ( const UEdGraphPin & Pin , FString & HoverTextOut ) const override ;
virtual bool ShowPaletteIconOnNode ( ) const override { return false ; }
2014-03-14 14:13:41 -04:00
// End of UEdGraphNode interface
// UK2Node interface
2014-06-13 06:14:46 -04:00
virtual bool NodeCausesStructuralBlueprintChange ( ) const override { return true ; }
virtual bool ShouldShowNodeProperties ( ) const override { return true ; }
virtual bool CanPlaceBreakpoints ( ) const override { return false ; }
2015-06-17 15:27:23 -04:00
virtual void ReallocatePinsDuringReconstruction ( TArray < UEdGraphPin * > & OldPins ) override ;
virtual bool CanCreateUnderSpecifiedSchema ( const UEdGraphSchema * DesiredSchema ) const override ;
virtual void GetNodeAttributes ( TArray < TKeyValuePair < FString , FString > > & OutNodeAttributes ) const override ;
virtual void GetMenuActions ( FBlueprintActionDatabaseRegistrar & ActionRegistrar ) const override ;
virtual FText GetMenuCategory ( ) const override ;
2014-07-14 09:38:51 -04:00
// By default return any animation assets we have
virtual UObject * GetJumpTargetForDoubleClick ( ) const override { return GetAnimationAsset ( ) ; }
2014-03-14 14:13:41 -04:00
// End of UK2Node interface
// UAnimGraphNode_Base interface
// Gets the menu category this node belongs in
2015-06-17 15:27:23 -04:00
virtual FString GetNodeCategory ( ) const ;
2014-03-14 14:13:41 -04:00
// Is this node a sink that has no pose outputs?
virtual bool IsSinkNode ( ) const { return false ; }
// Create any output pins necessary for this node
2015-06-17 15:27:23 -04:00
virtual void CreateOutputPins ( ) ;
2014-03-14 14:13:41 -04:00
// customize pin data based on the input
virtual void CustomizePinData ( UEdGraphPin * Pin , FName SourcePropertyName , int32 ArrayIndex ) const { }
// Gives each visual node a chance to do final validation before it's node is harvested for use at runtime
2015-06-17 15:27:23 -04:00
virtual void ValidateAnimNodeDuringCompilation ( USkeleton * ForSkeleton , FCompilerResultsLog & MessageLog ) { }
2014-03-14 14:13:41 -04:00
// Gives each visual node a chance to validate that they are still valid in the context of the compiled class, giving a last shot at error or warning generation after primary compilation is finished
2015-06-17 15:27:23 -04:00
virtual void ValidateAnimNodePostCompile ( FCompilerResultsLog & MessageLog , UAnimBlueprintGeneratedClass * CompiledClass , int32 CompiledNodeIndex ) { }
2014-03-14 14:13:41 -04:00
// Gives each visual node a chance to update the node template before it is inserted in the compiled class
2015-06-17 15:27:23 -04:00
virtual void BakeDataDuringCompilation ( FCompilerResultsLog & MessageLog ) { }
2014-03-14 14:13:41 -04:00
// preload asset required for this node in this function
virtual void PreloadRequiredAssets ( ) { }
// Give the node a chance to change the display name of a pin
2015-06-17 15:27:23 -04:00
virtual void PostProcessPinName ( const UEdGraphPin * Pin , FString & DisplayName ) const ;
2014-03-14 14:13:41 -04:00
/** Get the animation blueprint to which this node belongs */
UAnimBlueprint * GetAnimBlueprint ( ) const { return CastChecked < UAnimBlueprint > ( GetBlueprint ( ) ) ; }
// Populate the supplied arrays with the currently reffered to animation assets
virtual void GetAllAnimationSequencesReferred ( TArray < UAnimationAsset * > & ComplexAnims , TArray < UAnimSequence * > & AnimationSequences ) const { }
// Replace references to animations that exist in the supplied maps
virtual void ReplaceReferredAnimations ( const TMap < UAnimationAsset * , UAnimationAsset * > & ComplexAnimsMap , const TMap < UAnimSequence * , UAnimSequence * > & AnimSequenceMap ) { } ;
// Helper function for GetAllAnimationSequencesReferred
void HandleAnimReferenceCollection ( UAnimationAsset * AnimAsset , TArray < UAnimationAsset * > & ComplexAnims , TArray < UAnimSequence * > & AnimationSequences ) const ;
// Helper function for ReplaceReferredAnimations
template < class AssetType >
void HandleAnimReferenceReplacement ( AssetType * & OriginalAsset , const TMap < UAnimationAsset * , UAnimationAsset * > & ComplexAnimsMap , const TMap < UAnimSequence * , UAnimSequence * > & AnimSequenceMap ) ;
// BEGIN Interface to support transition getter
// if you return true for DoesSupportExposeTimeForTransitionGetter
// you should implement all below functions
virtual bool DoesSupportTimeForTransitionGetter ( ) const { return false ; }
2015-06-17 15:27:23 -04:00
virtual UAnimationAsset * GetAnimationAsset ( ) const { return nullptr ; }
virtual const TCHAR * GetTimePropertyName ( ) const { return nullptr ; }
virtual UScriptStruct * GetTimePropertyStruct ( ) const { return nullptr ; }
2014-03-14 14:13:41 -04:00
// END Interface to support transition getter
2014-09-22 09:45:11 -04:00
// can customize details tab
2015-06-17 15:27:23 -04:00
virtual void CustomizeDetails ( IDetailLayoutBuilder & DetailBuilder ) { }
2014-09-22 09:45:11 -04:00
2014-03-14 14:13:41 -04:00
protected :
2015-06-17 15:27:23 -04:00
friend FAnimBlueprintCompiler ;
friend FAnimGraphNodeDetails ;
2014-03-14 14:13:41 -04:00
// Gets the animation FNode type represented by this ed graph node
2015-06-17 15:27:23 -04:00
UScriptStruct * GetFNodeType ( ) const ;
2014-03-14 14:13:41 -04:00
// Gets the animation FNode property represented by this ed graph node
2015-06-17 15:27:23 -04:00
UStructProperty * GetFNodeProperty ( ) const ;
2014-03-14 14:13:41 -04:00
// This will be called when a pose link is found, and can be called with PoseProperty being either of:
// - an array property (ArrayIndex >= 0)
// - a single pose property (ArrayIndex == INDEX_NONE)
2015-06-17 15:27:23 -04:00
virtual void CreatePinsForPoseLink ( UProperty * PoseProperty , int32 ArrayIndex ) ;
2014-03-14 14:13:41 -04:00
//
2015-06-17 15:27:23 -04:00
virtual FPoseLinkMappingRecord GetLinkIDLocation ( const UScriptStruct * NodeType , UEdGraphPin * InputLinkPin ) ;
2014-03-14 14:13:41 -04:00
//
2015-06-17 15:27:23 -04:00
virtual void GetPinAssociatedProperty ( const UScriptStruct * NodeType , UEdGraphPin * InputPin , UProperty * & OutProperty , int32 & OutIndex ) ;
2014-03-14 14:13:41 -04:00
// Allocates or reallocates pins
2015-06-17 15:27:23 -04:00
void InternalPinCreation ( TArray < UEdGraphPin * > * OldPins ) ;
2014-03-14 14:13:41 -04:00
} ;
template < class AssetType >
void UAnimGraphNode_Base : : HandleAnimReferenceReplacement ( AssetType * & OriginalAsset , const TMap < UAnimationAsset * , UAnimationAsset * > & ComplexAnimsMap , const TMap < UAnimSequence * , UAnimSequence * > & AnimSequenceMap )
{
AssetType * CacheOriginalAsset = OriginalAsset ;
2015-06-17 15:27:23 -04:00
OriginalAsset = nullptr ;
2014-03-14 14:13:41 -04:00
2015-06-17 15:27:23 -04:00
if ( UAnimSequence * AnimSequence = Cast < UAnimSequence > ( CacheOriginalAsset ) )
2014-03-14 14:13:41 -04:00
{
2015-06-17 15:27:23 -04:00
if ( UAnimSequence * const * ReplacementAsset = AnimSequenceMap . Find ( AnimSequence ) )
2014-03-14 14:13:41 -04:00
{
OriginalAsset = Cast < AssetType > ( * ReplacementAsset ) ;
}
}
2015-06-17 15:27:23 -04:00
else if ( UAnimationAsset * AnimAsset = Cast < UAnimationAsset > ( CacheOriginalAsset ) )
2014-03-14 14:13:41 -04:00
{
2015-06-17 15:27:23 -04:00
if ( UAnimationAsset * const * ReplacementAsset = ComplexAnimsMap . Find ( AnimAsset ) )
2014-03-14 14:13:41 -04:00
{
OriginalAsset = Cast < AssetType > ( * ReplacementAsset ) ;
}
}
}