UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AnimExecutionContext.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"
6#include "AnimExecutionContext.generated.h"
7
11struct FPoseContext;
13
14// The result of an anim node context conversion
15UENUM(BlueprintType)
21
22// Context used to expose anim graph execution to BP function libraries
23USTRUCT(BlueprintType)
25{
27
28public:
29 // Internal data, weakly referenced
30 struct FData
31 {
32 public:
34
36
38
40
42
43 private:
44 friend struct FAnimExecutionContext;
46 friend struct FAnimUpdateContext;
47 friend struct FAnimPoseContext;
49
50 enum class EContextType
51 {
52 None,
53 Base,
55 Update,
56 Pose,
57 ComponentSpacePose,
58 };
59
60 // The context used when executing this node, e.g. FAnimationUpdateContext, FPoseContext etc.
62
63 // The phase we are in
64 EContextType ContextType = EContextType::None;
65 };
66
70
74
75 // Is this a valid context?
76 bool IsValid() const
77 {
78 return Data.IsValid();
79 }
80
81 // Convert to a derived type
82 template<typename OtherContextType>
84 {
85 static_assert(TIsDerivedFrom<OtherContextType, FAnimExecutionContext>::IsDerived, "Argument OtherContextType must derive from FAnimExecutionContext");
86
88 {
89 if(OtherContextType::InternalContextTypeId == PinnedData->ContextType)
90 {
92
94 Context.Data = InContext.Data;
95 return Context;
96 }
97 }
98
100
101 return OtherContextType();
102 }
103
104 // Access internal context. Will return nullptr if invalid
106 {
108 {
109 return PinnedData->Context;
110 }
111
112 return nullptr;
113 }
114
115protected:
116 // Access internal context. Will return nullptr if invalid or an incorrect type is requested
117 template<typename OtherContextType, typename InternalContextType>
119 {
121 {
122 if(OtherContextType::InternalContextTypeId == PinnedData->ContextType)
123 {
124 return static_cast<InternalContextType*>(PinnedData->Context);
125 }
126 }
127
128 return nullptr;
129 }
130
131protected:
132 // Internal data
134};
135
136USTRUCT()
138{
140
141public:
142 static const FData::EContextType InternalContextTypeId = FData::EContextType::Initialize;
143
145
152
154};
155
156USTRUCT()
158{
160
161public:
162 static const FData::EContextType InternalContextTypeId = FData::EContextType::Update;
163
165
172
174};
175
176USTRUCT()
178{
180
181public:
182 static const FData::EContextType InternalContextTypeId = FData::EContextType::Pose;
183
184 FAnimPoseContext() = default;
185
188 {
189 check(InData.IsValid());
190 check(InData.Pin()->ContextType == InternalContextTypeId);
191 }
192
194};
195
196USTRUCT()
198{
200
201public:
202 static const FData::EContextType InternalContextTypeId = FData::EContextType::ComponentSpacePose;
203
205
212
214};
EAnimExecutionContextConversionResult
Definition AnimExecutionContext.h:17
#define check(expr)
Definition AssertionMacros.h:314
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition SharedPointer.h:692
Definition SharedPointer.h:1295
Definition AnimExecutionContext.h:198
ENGINE_API FComponentSpacePoseContext * GetContext() const
Definition AnimExecutionContext.cpp:53
FAnimComponentSpacePoseContext(TWeakPtr< FData > InData)
Definition AnimExecutionContext.h:206
static const FData::EContextType InternalContextTypeId
Definition AnimExecutionContext.h:202
Definition AnimExecutionContext.h:31
Definition AnimExecutionContext.h:25
FAnimExecutionContext(TWeakPtr< FData > InData)
Definition AnimExecutionContext.h:71
bool IsValid() const
Definition AnimExecutionContext.h:76
InternalContextType * GetInternalContext() const
Definition AnimExecutionContext.h:118
static OtherContextType ConvertToType(const FAnimExecutionContext &InContext, EAnimExecutionContextConversionResult &OutResult)
Definition AnimExecutionContext.h:83
TWeakPtr< FData > Data
Definition AnimExecutionContext.h:133
FAnimExecutionContext & operator=(const FAnimExecutionContext &InOther)=default
FAnimExecutionContext(const FAnimExecutionContext &InOther)=default
FAnimExecutionContext()=default
FAnimationBaseContext * GetBaseContext() const
Definition AnimExecutionContext.h:105
Definition AnimExecutionContext.h:138
FAnimInitializationContext()=default
FAnimInitializationContext(TWeakPtr< FData > InData)
Definition AnimExecutionContext.h:146
Definition AnimExecutionContext.h:178
FAnimPoseContext(TWeakPtr< FData > InData)
Definition AnimExecutionContext.h:186
FAnimPoseContext()=default
Definition AnimExecutionContext.h:158
FAnimUpdateContext(TWeakPtr< FData > InData)
Definition AnimExecutionContext.h:166
FAnimUpdateContext()=default
Definition AnimNodeBase.h:159
Definition AnimNodeBase.h:324
Definition AnimNodeBase.h:354
Definition AnimNodeBase.h:600
Definition AnimNodeBase.h:479
Definition UnrealTypeTraits.h:40