UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PoseAsset.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
10#include "CoreMinimal.h"
12#include "Animation/SmartName.h"
16#include "PoseAsset.generated.h"
17
18class UAnimSequence;
19class USkeletalMeshComponent;
22class FPoseAssetDetails;
23
33USTRUCT()
35{
37
38#if WITH_EDITORONLY_DATA
39 // source local space pose, this pose is always full pose
40 // the size this array matches Tracks in the pose container
41 UPROPERTY()
43
44 // source curve data that is full value
45 UPROPERTY()
47#endif // WITH_EDITORONLY_DATA
48
49 // local space pose, # of array match with # of TrackToBufferIndex
50 // it only saves the one with delta as base pose or ref pose if full pose
51 UPROPERTY()
52 TArray<FTransform> LocalSpacePose;
53
54 // # of array match with # of Curves in PoseDataContainer
55 // curve data is not compressed
56 UPROPERTY()
57 TArray<float> CurveData;
58};
59
60USTRUCT()
62{
64
65 UPROPERTY()
66 int32 PoseIndex = INDEX_NONE;
67
68 UPROPERTY()
69 int32 BoneTransformIndex = INDEX_NONE;
70};
71
72USTRUCT()
80
86USTRUCT()
88{
90
91public:
94 ENGINE_API void PostSerialize(const FArchive& Ar);
95
96private:
97#if WITH_EDITORONLY_DATA
98 // pose names - horizontal data
99 UPROPERTY()
101#endif
102
103 // pose names - horizontal data
104 UPROPERTY()
105 TArray<FName> PoseFNames;
106
107 // Sorted curve name indices
108 TArray<int32> SortedCurveIndices;
109
110 // this is list of tracks - vertical data
111 UPROPERTY()
112 TArray<FName> Tracks;
113
114 // cache containting the skeleton indices for FName in Tracks array
116 TArray<int32> TrackBoneIndices;
117
118 UPROPERTY()
119 TArray<FPoseAssetInfluences> TrackPoseInfluenceIndices;
120
121 // this is list of poses
122 UPROPERTY()
123 TArray<FPoseData> Poses;
124
125
126 // curve meta data # of Curve UIDs should match with Poses.CurveValues.Num
127 UPROPERTY()
129
130 ENGINE_API void Reset();
131
132 ENGINE_API FPoseData* FindPoseData(FName PoseName);
133 ENGINE_API FPoseData* FindOrAddPoseData(FName PoseName);
134
135 int32 GetNumPoses() const { return Poses.Num(); }
136 bool Contains(FName PoseName) const { return PoseFNames.Contains(PoseName); }
137
138 bool IsValid() const { return PoseFNames.Num() == Poses.Num() && Tracks.Num() == TrackBoneIndices.Num(); }
139 ENGINE_API void GetPoseCurve(const FPoseData* PoseData, FBlendedCurve& OutCurve) const;
140 ENGINE_API void BlendPoseCurve(const FPoseData* PoseData, FBlendedCurve& OutCurve, float Weight) const;
141
142 // we have to delete tracks if skeleton has modified
143 // usually this may not be issue since once cooked, it should match
144 ENGINE_API void DeleteTrack(int32 TrackIndex);
145
146 // get default transform - it considers for retarget source if exists
147 ENGINE_API FTransform GetDefaultTransform(const FName& InTrackName, USkeleton* InSkeleton, const TArray<FTransform>& RefPose) const;
148 ENGINE_API FTransform GetDefaultTransform(int32 SkeletonIndex, const TArray<FTransform>& RefPose) const;
149
150#if WITH_EDITOR
154 ENGINE_API bool DeleteCurve(FName CurveName);
156
159
160 // editor features for full pose <-> additive pose
163#endif // WITH_EDITOR
164
165 ENGINE_API void RebuildCurveIndexTable();
166
167 friend class UPoseAsset;
168};
169
170template<>
172{
173 enum
174 {
177 };
178};
179
180
184UCLASS(MinimalAPI, BlueprintType)
186{
188
189private:
191 UPROPERTY()
192 struct FPoseDataContainer PoseContainer;
193
195 UPROPERTY(Category = Additive, EditAnywhere)
196 bool bAdditivePose;
197
199 UPROPERTY()
200 int32 BasePoseIndex;
201
202public:
204 UPROPERTY(Category=Animation, EditAnywhere)
205 FName RetargetSource;
206
207#if WITH_EDITORONLY_DATA
209 UE_DEPRECATED(5.5, "Direct access to RetargetSourceAsset has been deprecated. Please use members GetRetargetSourceAsset & SetRetargetSourceAsset instead.")
210 UPROPERTY(EditAnywhere, AssetRegistrySearchable, Category=Animation, meta = (DisallowedClasses = "/Script/ApexDestruction.DestructibleMesh"))
212#endif
213
215 UPROPERTY()
216 TArray<FTransform> RetargetSourceAssetReferencePose;
217
218#if WITH_EDITORONLY_DATA
219 UPROPERTY(Category=Source, EditAnywhere)
221
223 UPROPERTY()
225#endif // WITH_EDITORONLY_DATA
226
236 UE_DEPRECATED(4.26, "Use GetAnimationPose with other signature")
237 ENGINE_API bool GetAnimationPose(struct FCompactPose& OutPose, FBlendedCurve& OutCurve, const FAnimExtractContext& ExtractionContext) const;
239
240 UE_DEPRECATED(4.26, "Use GetBaseAnimationPose with other signature")
241 ENGINE_API void GetBaseAnimationPose(struct FCompactPose& OutPose, FBlendedCurve& OutCurve) const;
242 ENGINE_API void GetBaseAnimationPose(struct FAnimationPoseData& OutAnimationPoseData) const;
243
244 virtual bool HasRootMotion() const { return false; }
245 virtual bool IsValidAdditive() const { return bAdditivePose; }
246
247 // this is utility function that just cares by names to be used by live link
248 // this isn't fast. Use it at your caution
250
251 //Begin UObject Interface
252 virtual void PostLoad() override;
253 virtual bool IsPostLoadThreadSafe() const override;
254 virtual void Serialize(FArchive& Ar) override;
255 virtual void PreSave(FObjectPreSaveContext ObjectSaveContext) override;
256 virtual void GetAssetRegistryTags(FAssetRegistryTagsContext Context) const override;
257 UE_DEPRECATED(5.4, "Implement the version that takes FAssetRegistryTagsContext instead.")
258 virtual void GetAssetRegistryTags(TArray<FAssetRegistryTag>& OutTags) const override;
259//End UObject Interface
260
261public:
262 ENGINE_API int32 GetNumPoses() const;
263 ENGINE_API int32 GetNumCurves() const;
264 ENGINE_API int32 GetNumTracks() const;
265
266 UE_DEPRECATED(5.3, "Please use GetPoseFNames.")
267 ENGINE_API const TArray<FSmartName> GetPoseNames() const;
268
269 ENGINE_API const TArray<FName>& GetPoseFNames() const;
270 ENGINE_API const TArray<FName>& GetTrackNames() const;
271
272 UE_DEPRECATED(5.3, "Please use GetCurveFNames.")
273 ENGINE_API const TArray<FSmartName> GetCurveNames() const;
274
275 ENGINE_API const TArray<FName> GetCurveFNames() const;
276 ENGINE_API const TArray<FAnimCurveBase>& GetCurveData() const;
277 ENGINE_API const TArray<float> GetCurveValues(const int32 PoseIndex) const;
278
280 ENGINE_API const int32 GetTrackIndexByName(const FName& InTrackName) const;
281
286 ENGINE_API bool GetCurveValue(const int32 PoseIndex, const int32 CurveIndex, float& OutValue) const;
287
288 UE_DEPRECATED(5.3, "Please use ContainsPose that takes a FName.")
289 bool ContainsPose(const FSmartName& InPoseName) const { return PoseContainer.Contains(InPoseName.DisplayName); }
290 ENGINE_API bool ContainsPose(const FName& InPoseName) const;
291
292#if WITH_EDITOR
294 UFUNCTION(BlueprintCallable, Category=PoseAsset)
296
298 UFUNCTION(BlueprintPure, Category=PoseAsset)
299 void GetPoseNames(TArray<FName>& PoseNames) const;
300
302 UFUNCTION(BlueprintPure, Category=PoseAsset)
303 FName GetBasePoseName() const;
304
306 UFUNCTION(BlueprintCallable, Category=PoseAsset)
308
309 UE_DEPRECATED(5.3, "Please use AddPoseWithUniqueName.")
310 bool AddOrUpdatePoseWithUniqueName(const USkeletalMeshComponent* MeshComponent, FSmartName* OutPoseName = nullptr) { return false; }
311
312 ENGINE_API FName AddPoseWithUniqueName(const USkeletalMeshComponent* MeshComponent);
313
314 UE_DEPRECATED(5.3, "Please use AddOrUpdatePose that takes a FName.")
315 void AddOrUpdatePose(const FSmartName& PoseName, const USkeletalMeshComponent* MeshComponent, bool bUpdateCurves = true) { AddOrUpdatePose(PoseName.DisplayName, MeshComponent, bUpdateCurves); }
316
317 ENGINE_API void AddOrUpdatePose(const FName& PoseName, const USkeletalMeshComponent* MeshComponent, bool bUpdateCurves = true);
318
319 UE_DEPRECATED(5.3, "Please use AddReferencePose that takes a FName.")
320 ENGINE_API void AddReferencePose(const FSmartName& PoseName, const FReferenceSkeleton& ReferenceSkeleton);
321
322 ENGINE_API void AddReferencePose(const FName& PoseName, const FReferenceSkeleton& ReferenceSkeleton);
323
324 UE_DEPRECATED(5.3, "Please use CreatePoseFromAnimation that takes a ptr to an array of FNames.")
325 void CreatePoseFromAnimation(class UAnimSequence* AnimSequence, const TArray<FSmartName>* InPoseNames) {}
326
327 ENGINE_API void CreatePoseFromAnimation(class UAnimSequence* AnimSequence, const TArray<FName>* InPoseNames = nullptr);
328
330 UFUNCTION(BlueprintCallable, Category=PoseAsset)
331 ENGINE_API void UpdatePoseFromAnimation(class UAnimSequence* AnimSequence);
332
333 // Begin AnimationAsset interface
334 virtual bool GetAllAnimationSequencesReferred(TArray<UAnimationAsset*>& AnimationAssets, bool bRecursive = true) override;
335 virtual void ReplaceReferredAnimations(const TMap<UAnimationAsset*, UAnimationAsset*>& ReplacementMap) override;
336 // End AnimationAsset interface
337
338 UE_DEPRECATED(5.3, "Please use ModifyPoseName that does not take a UID.")
340
342
343
344 UE_DEPRECATED(5.3, "Please use RenamePoseOrCurveName.")
346
347 // Rename poses or curves using the names supplied
349
350 UE_DEPRECATED(5.3, "Please use RemovePoseOrCurveNames.")
352
353 // Remove poses or curves using the names supplied
355
356 // editor interface
357 virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
358 // Return full (local space, non additive) pose. Will do conversion if PoseAsset is Additive.
359 ENGINE_API bool GetFullPose(int32 PoseIndex, TArray<FTransform>& OutTransforms) const;
360
361 // util to return transform of a bone from the pose asset in component space, by walking up tracks in pose asset */
362 ENGINE_API FTransform GetComponentSpaceTransform(FName BoneName, const TArray<FTransform>& LocalTransforms) const;
363
364 // util to return transform of a bone from the pose asset in local space */
365 ENGINE_API const FTransform& GetLocalSpaceTransform(FName BoneName, int32 PoseIndex = 0) const;
366
370 const FName GetPoseNameByIndex(int32 InBasePoseIndex) const { return PoseContainer.PoseFNames.IsValidIndex(InBasePoseIndex) ? PoseContainer.PoseFNames[InBasePoseIndex] : NAME_None; }
371#endif // WITH_EDITOR
372
373 int32 GetBasePoseIndex() const { return BasePoseIndex; }
374 ENGINE_API const int32 GetPoseIndexByName(const FName& InBasePoseName) const;
375 ENGINE_API const int32 GetCurveIndexByName(const FName& InCurveName) const;
376
377#if WITH_EDITOR
378private:
381
382public:
383 typedef FOnPoseListChangedMulticaster::FDelegate FOnPoseListChanged;
384
387 {
388 return OnPoseListChanged.Add(Delegate);
389 }
392 {
394 }
395
396 UE_DEPRECATED(5.3, "Please use GetUniquePoseName scoped to this pose asset.")
398 UE_DEPRECATED(5.3, "Please use GetUniquePoseName.")
400
403
406private:
407 // this will do multiple things, it will add tracks and make sure it fix up all poses with it
408 // use same as retarget source system we have for animation
409 void CombineTracks(const TArray<FName>& NewTracks);
410
411 void ConvertToFullPose();
413 bool GetBasePoseTransform(TArray<FTransform>& OutBasePose, TArray<float>& OutCurve) const;
414 void Reinitialize();
415
416 // After any update to SourceLocalPoses, this does update runtime data
417 void AddOrUpdatePose(const FName& PoseName, const TArray<FName>& TrackNames, const TArray<FTransform>& LocalTransform, const TArray<float>& CurveValues);
418 void PostProcessData();
420#endif // WITH_EDITOR
421
422private:
423 void UpdateTrackBoneIndices();
424 bool RemoveInvalidTracks();
425
426public:
427#if WITH_EDITOR
428 // Assigns the passed skeletal mesh to the retarget source
429 UFUNCTION(BlueprintCallable, Category = "Animation")
431
432 // Resets the retarget source asset
433 UFUNCTION(BlueprintCallable, Category = "Animation")
435
436 // Returns the retarget source asset soft object pointer.
437 UFUNCTION(BlueprintPure, Category = "Animation")
439
440 // Update the retarget data pose from the source, if it exist, else clears the retarget data pose saved in RetargetSourceAssetReferencePose.
441 // Warning : This function calls LoadSynchronous at the retarget source asset soft object pointer, so it can not be used at PostLoad
442 UFUNCTION(BlueprintCallable, Category = "Animation")
444#endif
445
446private:
447 const TArray<FTransform>& GetRetargetTransforms() const;
448 FName GetRetargetTransformsSourceName() const;
449
450 friend class FPoseAssetDetails;
451};
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
virtual bool IsPostLoadThreadSafe() const override
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#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
void GetCurveValues(const TArray< const TCHAR * > &Cells, TArray< float > &Values)
Definition CurveTable.cpp:630
#define DECLARE_MULTICAST_DELEGATE(DelegateName)
Definition DelegateCombinations.h:23
return true
Definition ExternalRpcRegistry.cpp:601
const bool
Definition NetworkReplayStreaming.h:178
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define GENERATED_UCLASS_BODY(...)
Definition ObjectMacros.h:768
#define UCLASS(...)
Definition ObjectMacros.h:776
#define USTRUCT(...)
Definition ObjectMacros.h:746
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
FTransform GetComponentSpaceTransform(TArray< uint8 > &ComponentSpaceFlags, TArray< FTransform > &ComponentSpaceTransforms, FReferenceSkeleton &RefSkeleton, int32 TargetIndex)
Definition ReferenceSkeleton.cpp:87
Definition Archive.h:1208
Definition AssetRegistryTagsContext.h:98
Definition IDelegateInstance.h:14
Definition NameTypes.h:617
Definition ObjectSaveContext.h:244
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
bool Contains(const ComparisonType &Item) const
Definition Array.h:1518
UE_NODEBUG UE_FORCEINLINE_HINT bool IsValidIndex(SizeType Index) const
Definition Array.h:1122
Definition UnrealString.h.inl:34
Definition AnimSequence.h:203
Definition AnimationAsset.h:1020
Definition PoseAsset.h:186
virtual bool IsValidAdditive() const
Definition PoseAsset.h:245
int32 GetBasePoseIndex() const
Definition PoseAsset.h:373
Definition SkeletalMesh.h:440
Definition Skeleton.h:295
Definition AnimationAsset.h:38
Definition AnimCurveTypes.h:93
Definition AnimationAsset.h:267
Definition AnimationPoseData.h:16
Definition AnimCurveTypes.h:1041
Definition BonePose.h:347
Definition Guid.h:109
Definition LiveLinkTypes.h:626
Definition PoseAsset.h:62
Definition PoseAsset.h:74
Definition PoseAsset.h:88
Definition PoseAsset.h:35
Definition UnrealType.h:6865
Definition ReferenceSkeleton.h:100
Definition SmartName.h:211
Definition ObjectPtr.h:488
Definition SoftObjectPtr.h:174
Definition StructOpsTypeTraits.h:11
@ WithSerializer
Definition StructOpsTypeTraits.h:23
@ WithPostSerialize
Definition StructOpsTypeTraits.h:25
Definition StructOpsTypeTraits.h:46