UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
BlendProfile.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
7#include "UObject/Object.h"
8#include "BoneContainer.h"
9#include "AnimationRuntime.h"
10#include "BlendProfile.generated.h"
11
12#define UE_API ENGINE_API
13
14struct FAlphaBlend;
15struct FCompactPose;
16struct FBlendedCurve;
18namespace UE { namespace Anim { struct FStackAttributeContainer; } }
19
21UENUM()
23{
24 // The bone's transition time is a factor based on the transition time.
25 // For example 0.5 means it takes half the time of the transition.
26 // Values should be between 0 and 1. They will be clamped if they go out of this range.
27 // A bone value of 0 means the bone will instantly transition into the target state.
28 TimeFactor = 0,
29
30 // The bone's transition weight is multiplied by this factor.
31 // For example 2.0 means the bone's blend weight is twice as high as the transition's blend weight.
32 // Values should typically be equal or greater than 1.0.
33 // If you want certain bones to instantly transition into the target state
34 // the Time Factor based method might be a better choice.
36
37 // Used for blend masks. Per bone alpha
39};
40
42USTRUCT()
44{
46
47 UPROPERTY(EditAnywhere, Category=BoneSettings)
48 FBoneReference BoneReference;
49
50 UPROPERTY(EditAnywhere, Category=BoneSettings)
51 float BlendScale = 0.f;
52};
53
55{
56public:
57 virtual ~IBlendProfileInterface() = default;
58
59 virtual float GetBoneBlendScale(int32 InBoneIdx) const = 0;
60
61 virtual int32 GetNumBlendEntries() const = 0;
62
64
65 virtual EBlendProfileMode GetMode() const = 0;
66
67 void UpdateBoneWeights(FBlendSampleData& InOutCurrentData, const FAlphaBlend& BlendInfo, float BlendStartAlpha, float MainWeight, bool bInverse = false) const;
68};
69
70class UBlendProfile;
71
72UINTERFACE(MinimalAPI, Blueprintable)
77
82{
84
85public:
86 // Convert the custom internal data struct into a regular blend profile
88};
89
94USTRUCT()
96{
98
99public:
100 UE_API void UpdateCachedBlendProfile();
101
102 const TObjectPtr<UBlendProfile> GetBlendProfile() const { return BlendProfile; }
103
104 TObjectPtr<UObject> GetCustomProviderObject() const { return BlendProfileProvider.GetObject(); }
105
107
108 UE_API void SetSkeletonBlendProfile(TObjectPtr<UBlendProfile> InBlendProfile);
109
110 bool UsesSkeletonBlendProfile() const { return BlendProfileProvider.GetObject() == nullptr; }
111
112private:
113 UPROPERTY()
114 bool bIsSkeletonBlendProfile = true;
115
116 // The object responsible for constructing the blend profile
117 UPROPERTY()
119
120 // The actual blend profile to use
121 UPROPERTY()
122 TObjectPtr<UBlendProfile> BlendProfile;
123};
124
126
130UCLASS(MinimalAPI, BlueprintType)
132{
133public:
134
136
138
140 int32 GetNumBlendEntries() const { return ProfileEntries.Num(); }
141
148 ENGINE_API void SetBoneBlendScale(int32 InBoneIdx, float InScale, bool bRecurse = false, bool bCreate = false);
149
156 ENGINE_API void SetBoneBlendScale(const FName& InBoneName, float InScale, bool bRecurse = false, bool bCreate = false);
157
161 ENGINE_API void RemoveEntry(int32 InBoneIdx);
162
166 ENGINE_API void RefreshBoneEntry(int32 InBoneIndex);
167
169 ENGINE_API void RefreshBoneEntriesFromName();
170
172 ENGINE_API void CleanupBoneEntries();
173
174 TObjectPtr<USkeleton> GetSkeleton() const override { return OwningSkeleton; }
175
181 ENGINE_API const FBlendProfileBoneEntry& GetEntry(const int32 InEntryIdx) const;
182
186 ENGINE_API float GetBoneBlendScale(int32 InBoneIdx) const override;
187
191 ENGINE_API float GetBoneBlendScale(const FName& InBoneName) const;
192
193 UE_DEPRECATED(5.0, "Please use the overload that takes a skeleton bone index")
194 ENGINE_API int32 GetEntryIndex(const int32 InBoneIdx) const;
195
199 ENGINE_API int32 GetEntryIndex(const FSkeletonPoseBoneIndex InBoneIdx) const;
200
204 ENGINE_API int32 GetEntryIndex(const FName& BoneName) const;
205
209 ENGINE_API float GetEntryBlendScale(const int32 InEntryIdx) const;
210
220 ENGINE_API void UpdateBoneWeights(FBlendSampleData& InOutCurrentData, const FAlphaBlend& BlendInfo, float BlendStartAlpha, float MainWeight, bool bInverse = false);
221
231 static ENGINE_API float CalculateBoneWeight(float BoneFactor, EBlendProfileMode Mode, const FAlphaBlend& BlendInfo, float BlendStartAlpha, float MainWeight, bool bInverse = false);
232
237 ENGINE_API void FillBoneScalesArray(TArray<float>& OutBoneBlendProfileFactors, const FBoneContainer& BoneContainer) const;
238
243 UE_DEPRECATED(5.4, "Please use the FillSkeletonBoneDurationsArray that takes a target skeleton as parameter.")
244 ENGINE_API void FillSkeletonBoneDurationsArray(TCustomBoneIndexArrayView<float, FSkeletonPoseBoneIndex> OutDurationPerBone, float Duration) const;
245
251 ENGINE_API void FillSkeletonBoneDurationsArray(TCustomBoneIndexArrayView<float, FSkeletonPoseBoneIndex> OutDurationPerBone, float Duration, const USkeleton* TargetSkeleton) const;
252
253 // IInterpolationIndexProvider
254 ENGINE_API virtual int32 GetPerBoneInterpolationIndex(const FCompactPoseBoneIndex& InCompactPoseBoneIndex, const FBoneContainer& BoneContainer, const IInterpolationIndexProvider::FPerBoneInterpolationData* Data) const override;
255 ENGINE_API virtual int32 GetPerBoneInterpolationIndex(const FSkeletonPoseBoneIndex InSkeletonBoneIndex, const USkeleton* TargetSkeleton, const IInterpolationIndexProvider::FPerBoneInterpolationData* Data) const override;
256 // End IInterpolationIndexProvider
257
258 // UObject
259 virtual bool IsSafeForRootSet() const override {return false;}
260 ENGINE_API virtual void PostLoad() override;
261 // End UObject
262
263 // Default value of entries. Default values are not saved
264 virtual float GetDefaultBlendScale() const { return IsBlendMask() ? 0.0f : 1.0f; }
265
266 bool IsBlendMask() const { return Mode == EBlendProfileMode::BlendMask; }
267
268 EBlendProfileMode GetMode() const { return Mode; }
269
271 ENGINE_API void SetSkeleton(USkeleton* InSkeleton);
272
273 // Empties the bone enties array
274 void ClearEntries();
275
276private:
278 ENGINE_API void SetSingleBoneBlendScale(int32 InBoneIdx, float InScale, bool bCreate = false);
279
280public:
281 // The skeleton that owns this profile
282 UPROPERTY()
283 TObjectPtr<USkeleton> OwningSkeleton;
284
285 // List of blend scale entries
286 UPROPERTY()
288
289 // Blend Profile Mode. Read EBlendProfileMode for more details
290 UPROPERTY()
292};
293
294#undef UE_API
#define UE_API
Definition BlendProfile.h:12
EBlendProfileMode
Definition BlendProfile.h:23
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
return true
Definition ExternalRpcRegistry.cpp:601
const bool
Definition NetworkReplayStreaming.h:178
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UINTERFACE(...)
Definition ObjectMacros.h:780
#define UCLASS(...)
Definition ObjectMacros.h:776
#define UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition NameTypes.h:617
Definition BlendProfile.h:55
virtual ~IBlendProfileInterface()=default
virtual TObjectPtr< USkeleton > GetSkeleton() const =0
virtual float GetBoneBlendScale(int32 InBoneIdx) const =0
virtual EBlendProfileMode GetMode() const =0
virtual int32 GetNumBlendEntries() const =0
Definition BlendProfile.h:82
virtual void ConstructBlendProfile(const TObjectPtr< UBlendProfile > OutBlendProfile) const =0
Definition AnimationRuntime.h:74
Definition Array.h:670
Definition ScriptInterface.h:139
Definition BlendProfile.h:74
Definition BlendProfile.h:132
TObjectPtr< USkeleton > GetSkeleton() const override
Definition BlendProfile.h:174
virtual float GetDefaultBlendScale() const
Definition BlendProfile.h:264
bool IsBlendMask() const
Definition BlendProfile.h:266
int32 GetNumBlendEntries() const
Definition BlendProfile.h:140
EBlendProfileMode GetMode() const
Definition BlendProfile.h:268
Definition CustomBoneIndexArray.h:43
Definition Interface.h:19
Definition Object.h:95
Definition Skeleton.h:295
Definition AdvancedWidgetsModule.cpp:13
@ false
Definition radaudio_common.h:23
Definition AlphaBlend.h:71
Definition BlendProfile.h:44
Definition BlendProfile.h:96
TObjectPtr< UObject > GetCustomProviderObject() const
Definition BlendProfile.h:104
bool UsesSkeletonBlendProfile() const
Definition BlendProfile.h:110
const TObjectPtr< UBlendProfile > GetBlendProfile() const
Definition BlendProfile.h:102
Definition AnimationAsset.h:122
Definition AnimCurveTypes.h:1041
Definition BoneContainer.h:192
Definition BoneReference.h:14
Definition BoneIndices.h:63
Definition BonePose.h:347
Definition BoneIndices.h:79
Definition AnimSlotEvaluationPose.h:14
Definition ObjectPtr.h:488