UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AnimNode_LayeredBoneBlend.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"
10#include "AnimNode_LayeredBoneBlend.generated.h"
11
12UENUM()
18
19// Layered blend (per bone); has dynamic number of blendposes that can blend per different bone sets
20USTRUCT(BlueprintInternalUseOnly)
22{
24
25public:
27 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Links)
28 FPoseLink BasePose;
29
31 UPROPERTY(EditAnywhere, BlueprintReadWrite, editfixedsize, Category=Links, meta=(BlueprintCompilerGeneratedDefaults))
32 TArray<FPoseLink> BlendPoses;
33
35 UPROPERTY(EditAnywhere, Category = Config)
37
42 UPROPERTY(EditAnywhere, editfixedsize, Category=Config, meta=(UseAsBlendMask=true))
44
50 UPROPERTY(EditAnywhere, editfixedsize, Category=Config)
52
54 UPROPERTY(EditAnywhere, BlueprintReadWrite, editfixedsize, Category=Runtime, meta=(BlueprintCompilerGeneratedDefaults, PinShownByDefault))
55 TArray<float> BlendWeights;
56
58 // transient data to handle weight and target weight
59 // this array changes based on required bones
60 TArray<FPerBoneBlendWeight> DesiredBoneBlendWeights;
61 TArray<FPerBoneBlendWeight> CurrentBoneBlendWeights;
62
63 // Per-bone weights for the skeleton. Serialized as these are only relative to the skeleton, but can potentially
64 // be regenerated at runtime if the GUIDs dont match
65 UPROPERTY()
66 TArray<FPerBoneBlendWeight> PerBoneBlendWeights;
67
68 // Per-curve source pose index
69 TBaseBlendedCurve<FDefaultAllocator, UE::Anim::FCurveElementIndexed> CurvePoseSourceIndices;
70
71 // Guids for skeleton used to determine whether the PerBoneBlendWeights need rebuilding
72 UPROPERTY()
73 FGuid SkeletonGuid;
74
75 // Guid for virtual bones used to determine whether the PerBoneBlendWeights need rebuilding
76 UPROPERTY()
77 FGuid VirtualBoneGuid;
78
79 // Serial number of the required bones container
80 uint16 RequiredBonesSerialNumber;
81
82public:
83 /*
84 * Max LOD that this node is allowed to run
85 * For example if you have LODThreshold to be 2, it will run until LOD 2 (based on 0 index)
86 * when the component LOD becomes 3, it will stop update/evaluate
87 * currently transition would be issue and that has to be re-visited
88 */
89 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Performance, meta = (DisplayName = "LOD Threshold"))
90 int32 LODThreshold;
91
93 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Config)
94 bool bMeshSpaceRotationBlend;
95
97 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Config, Meta = (Editcondition = bMeshSpaceRotationBlend))
98 bool bRootSpaceRotationBlend;
99
101 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Config)
102 bool bMeshSpaceScaleBlend;
103
105 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Config)
106 TEnumAsByte<enum ECurveBlendOption::Type> CurveBlendOption;
107
109 UPROPERTY(EditAnywhere, Category = Config)
110 bool bBlendRootMotionBasedOnRootBone;
111
112 bool bHasRelevantPoses;
113
116 , RequiredBonesSerialNumber(0)
117 , LODThreshold(INDEX_NONE)
118 , bMeshSpaceRotationBlend(false)
119 , bRootSpaceRotationBlend(false)
120 , bMeshSpaceScaleBlend(false)
121 , CurveBlendOption(ECurveBlendOption::Override)
122 , bBlendRootMotionBasedOnRootBone(true)
123 , bHasRelevantPoses(false)
124 {
125 }
126
127 // FAnimNode_Base interface
128 ANIMGRAPHRUNTIME_API virtual void Initialize_AnyThread(const FAnimationInitializeContext& Context) override;
129 ANIMGRAPHRUNTIME_API virtual void CacheBones_AnyThread(const FAnimationCacheBonesContext& Context) override;
130 ANIMGRAPHRUNTIME_API virtual void Update_AnyThread(const FAnimationUpdateContext& Context) override;
131 ANIMGRAPHRUNTIME_API virtual void Evaluate_AnyThread(FPoseContext& Output) override;
132 ANIMGRAPHRUNTIME_API virtual void GatherDebugData(FNodeDebugData& DebugData) override;
133 virtual int32 GetLODThreshold() const override { return LODThreshold; }
134 // End of FAnimNode_Base interface
135
136 void AddPose()
137 {
138 BlendWeights.Add(1.f);
139 BlendPoses.AddDefaulted();
140 SyncBlendMasksAndLayers();
141 }
142
143 void RemovePose(int32 PoseIndex)
144 {
145 BlendWeights.RemoveAt(PoseIndex);
146 BlendPoses.RemoveAt(PoseIndex);
147
148 if (BlendMasks.IsValidIndex(PoseIndex))
149 {
150 BlendMasks.RemoveAt(PoseIndex);
151 }
152
153 if (LayerSetup.IsValidIndex(PoseIndex))
154 {
155 LayerSetup.RemoveAt(PoseIndex);
156 }
157 // just in case, we've seen problems.
158 SyncBlendMasksAndLayers();
159 }
160
161 // Set the blend mask for the specified input pose
163
164 // Invalidate the cached per-bone blend weights from the skeleton
165 void InvalidatePerBoneBlendWeights() { RequiredBonesSerialNumber = 0; SkeletonGuid = FGuid(); VirtualBoneGuid = FGuid(); }
166
167 // Invalidates the cached bone data so it is recalculated the next time this node is updated
168 void InvalidateCachedBoneData() { RequiredBonesSerialNumber = 0; }
169
170private:
171
172 // just for the graph constructor to call.
173 void AddFirstPose()
174 {
175 check(BlendWeights.IsEmpty());
176 BlendWeights.Add(1.f);
177 BlendPoses.AddDefaulted();
179 LayerSetup.AddDefaulted();
180 }
181
182 // Synchronize the number of BlendMasks or Layers with the number of BlendPoses.
183 ANIMGRAPHRUNTIME_API void SyncBlendMasksAndLayers();
184
185 // Rebuild cache per bone blend weights from the skeleton
186 ANIMGRAPHRUNTIME_API void RebuildPerBoneBlendWeights(const USkeleton* InSkeleton);
187
188 // Check whether per-bone blend weights are valid according to the skeleton (GUID check)
189 ANIMGRAPHRUNTIME_API bool ArePerBoneBlendWeightsValid(const USkeleton* InSkeleton) const;
190
191 // Update cached data if required
192 ANIMGRAPHRUNTIME_API void UpdateCachedBoneData(const FBoneContainer& RequiredBones, const USkeleton* Skeleton);
193
194 friend class UAnimGraphNode_LayeredBoneBlend;
195};
ELayeredBoneBlendMode
Definition AnimNode_LayeredBoneBlend.h:14
#define check(expr)
Definition AssertionMacros.h:314
@ INDEX_NONE
Definition CoreMiscDefines.h:150
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
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
uint8_t uint8
Definition binka_ue_file_header.h:8
uint16_t uint16
Definition binka_ue_file_header.h:7
Definition Array.h:670
Definition EnumAsByte.h:22
Definition ContainerAllocationPolicies.h:830
Definition BlendProfile.h:132
Definition Skeleton.h:295
Definition AnimTypes.h:587
Definition AdvancedWidgetsModule.cpp:13
@ false
Definition radaudio_common.h:23
Definition AnimNodeBase.h:853
Definition AnimNode_LayeredBoneBlend.h:22
void InvalidatePerBoneBlendWeights()
Definition AnimNode_LayeredBoneBlend.h:165
void AddPose()
Definition AnimNode_LayeredBoneBlend.h:136
void RemovePose(int32 PoseIndex)
Definition AnimNode_LayeredBoneBlend.h:143
void InvalidateCachedBoneData()
Definition AnimNode_LayeredBoneBlend.h:168
virtual int32 GetLODThreshold() const override
Definition AnimNode_LayeredBoneBlend.h:133
Definition AnimNodeBase.h:337
Definition AnimNodeBase.h:324
Definition AnimNodeBase.h:354
Definition BoneContainer.h:192
Definition Guid.h:109
Definition BoneMaskFilter.h:31
Definition AnimNodeBase.h:642
Definition AnimTypes.h:113
Definition AnimNodeBase.h:479
Definition AnimCurveTypes.h:487
Definition ObjectPtr.h:488