// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "Animation/AttributesContainer.h" #include "Animation/BlendProfile.h" #include "HierarchyTable.h" #include "HierarchyTableBlendProfile.generated.h" #define UE_API HIERARCHYTABLEANIMATIONRUNTIME_API USTRUCT() struct FMaskedAttributeWeightSerialised { GENERATED_BODY() UPROPERTY() FName AttributeNamespace; UPROPERTY() FName AttributeName; UPROPERTY() int32 AttributeIndex = INDEX_NONE; UPROPERTY() float Weight = 0.0f; }; USTRUCT() struct FMaskedCurveWeightSerialised { GENERATED_BODY() UPROPERTY() FName CurveName; UPROPERTY() float Weight = 0.0f; }; USTRUCT() struct FBlendProfileStandaloneCachedData { GENERATED_BODY() public: UE_API void UnpackCachedData(); UE_API void Init(TObjectPtr InHierarchyTable, const EBlendProfileMode InMode); UE_API void Reset(); struct FNamedFloat { FName Name; float Value; FNamedFloat(const FName InName, const float InValue) : Name(InName) , Value(InValue) { } }; struct FMaskedAttributeWeight { UE::Anim::FAttributeId Attribute; float Weight; FMaskedAttributeWeight(const UE::Anim::FAttributeId InAttribute, const float InWeight) : Attribute(InAttribute) , Weight(InWeight) { } }; UE_API const TArray& GetBoneBlendWeights() const; UE_API const UE::Anim::TNamedValueArray& GetCurveBlendWeights() const; UE_API const TArray& GetAttributeBlendWeights() const; UE_API void ConstructBlendProfile(const TObjectPtr OutBlendProfile) const; UE_API bool IsValidBoneIndex(const int32 BoneIndex) const; UE_API TObjectPtr GetSkeleton() const; private: UPROPERTY() TObjectPtr Skeleton; UPROPERTY() TArray BoneBlendWeights; UPROPERTY() TArray SerializedCurveBlendWeights; UPROPERTY() TArray SerializedAttributeBlendWeights; UPROPERTY() EBlendProfileMode Mode = EBlendProfileMode::WeightFactor; private: UE::Anim::TNamedValueArray CurveBlendWeights; TArray AttributeBlendWeights; }; class FHierarchyTableBlendProfile : public IBlendProfileInterface { public: FHierarchyTableBlendProfile() = default; virtual ~FHierarchyTableBlendProfile() = default; UE_API FHierarchyTableBlendProfile(TObjectPtr InHierarchyTable, const EBlendProfileMode InMode); UE_API FHierarchyTableBlendProfile(const TObjectPtr InSkeleton, const EBlendProfileMode InMode); // IBlendProfileInterface UE_API virtual float GetBoneBlendScale(int32 InBoneIdx) const override; UE_API virtual int32 GetNumBlendEntries() const override; UE_API virtual int32 GetPerBoneInterpolationIndex(const FCompactPoseBoneIndex& InCompactPoseBoneIndex, const FBoneContainer& BoneContainer, const IInterpolationIndexProvider::FPerBoneInterpolationData* Data) const override; UE_API virtual int32 GetPerBoneInterpolationIndex(const FSkeletonPoseBoneIndex InSkeletonBoneIndex, const USkeleton* TargetSkeleton, const IInterpolationIndexProvider::FPerBoneInterpolationData* Data) const override; UE_API virtual EBlendProfileMode GetMode() const override; UE_API virtual TObjectPtr GetSkeleton() const override; struct FMaskedAttributeWeight { UE::Anim::FAttributeId Attribute; float Weight; FMaskedAttributeWeight(const UE::Anim::FAttributeId InAttribute, const float InWeight) : Attribute(InAttribute) , Weight(InWeight) { } }; UE_API const UE::Anim::TNamedValueArray& GetCurveBlendWeights() const; UE_API const TArray& GetAttributeBlendWeights() const; UE_API void ConstructBlendProfile(const TObjectPtr OutBlendProfile) const; UE_API bool IsValidBoneIndex(const int32 BoneIndex) const; private: TObjectPtr Skeleton; TArray BoneBlendWeights; UE::Anim::TNamedValueArray CurveBlendWeights; TArray AttributeBlendWeights; EBlendProfileMode Mode = EBlendProfileMode::WeightFactor; }; #undef UE_API