text: // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
  
  #pragma once
  
  #include "Animation/AnimNodeBase.h"
  #include "Animation/AnimData/BoneMaskFilter.h"
  #include "Animation/AnimTypes.h"
  #include "AnimNode_LayeredBoneBlend.generated.h"
  
  
  // Layered blend (per bone); has dynamic number of blendposes that can blend per different bone sets
  USTRUCT()
  struct ANIMGRAPHRUNTIME_API FAnimNode_LayeredBoneBlend : public FAnimNode_Base
  {
  	GENERATED_USTRUCT_BODY()
  
  public:
  	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Links)
  	FPoseLink BasePose;
  
  	//@TODO: Anim: Comment these members
  	UPROPERTY(EditAnywhere, BlueprintReadWrite, editfixedsize, Category=Links)
  	TArray<FPoseLink> BlendPoses;
  
  	UPROPERTY(EditAnywhere, BlueprintReadWrite, editfixedsize, Category=Config)
  	TArray<FInputBlendPose> LayerSetup;
  
  	UPROPERTY(EditAnywhere, BlueprintReadWrite, editfixedsize, Category=Runtime, meta=(PinShownByDefault))
  	TArray<float> BlendWeights;
  
  	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Config)
  	bool bMeshSpaceRotationBlend;
  	
  	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Config)
  	TEnumAsByte<enum ECurveBlendOption::Type>	CurveBlendOption;
  
  	UPROPERTY(Transient)
  	bool bHasRelevantPoses;
  
  protected:
  	TArray<FPerBoneBlendWeight> DesiredBoneBlendWeights;
  	TArray<FPerBoneBlendWeight> CurrentBoneBlendWeights;
  
  public:	
  	FAnimNode_LayeredBoneBlend()
  	{
  	}
  
  	// FAnimNode_Base interface
  	virtual void Initialize(const FAnimationInitializeContext& Context) override;
  	virtual void CacheBones(const FAnimationCacheBonesContext& Context) override;
  	virtual void Update(const FAnimationUpdateContext& Context) override;
  	virtual void Evaluate(FPoseContext& Output) override;
  	virtual void GatherDebugData(FNodeDebugData& DebugData) override;
  	// End of FAnimNode_Base interface
  
  #if WITH_EDITOR
  	void AddPose()
  	{
  		BlendWeights.Add(1.f);
  		new (BlendPoses) FPoseLink();
  		new (LayerSetup) FInputBlendPose();
  	}
  
  	void RemovePose(int32 PoseIndex)
  	{
  		BlendWeights.RemoveAt(PoseIndex);
  		BlendPoses.RemoveAt(PoseIndex);
  		LayerSetup.RemoveAt(PoseIndex);
  	}
  
  	// ideally you don't like to get to situation where it becomes inconsistent, but this happened, 
  	// and we don't know what caused this. Possibly copy/paste, but I tried copy/paste and that didn't work
  	// so here we add code to fix this up manually in editor, so that they can continue working on it. 
  	void ValidateData();
  #endif
  
  	void ReinitializeBoneBlendWeights(const FBoneContainer& RequiredBones, const USkeleton* Skeleton);
  };
  