UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AnimNotifyQueue.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 "Math/RandomStream.h"
9#include "AnimNotifyQueue.generated.h"
10
11#define UE_API ENGINE_API
12
13class USkeletalMeshComponent;
15struct FAnimNotifyEvent;
17struct FAnimTickRecord;
18class UWorld;
19
20USTRUCT(BlueprintType)
22{
24
26
28 : Notify(InNotify)
29 , MirrorTable(nullptr)
30 , NotifySource(InNotifySource)
31 {}
32
34 : Notify(InNotify)
35 , MirrorTable(MirrorDataTable)
36 , NotifySource(InNotifySource)
37 {}
38
39
41 {
42 return NotifySource ? Notify : nullptr;
43 }
44
46 {
47 if (NotifySource)
48 {
49 Notify = InNotify;
50 }
51 }
52
54 {
55 return MirrorTable.Get();
56 }
57
59 {
60 return(
61 (Lhs.Notify == Rhs.Notify) ||
62 (Lhs.Notify && Rhs.Notify && *Lhs.Notify == *Rhs.Notify)
63 );
64 }
65
66 friend bool operator==(const FAnimNotifyEventReference& Lhs, const FAnimNotifyEvent& Rhs);
67
68 template<typename Type>
69 const Type* GetContextData() const
70 {
71 if(ContextData.IsValid())
72 {
73 for(const TUniquePtr<const UE::Anim::IAnimNotifyEventContextDataInterface>& DataInterface : *ContextData)
74 {
75 if (DataInterface->Is<Type>())
76 {
77 return &(DataInterface->As<Type>());
78 }
79 }
80 }
81 return nullptr;
82 }
83
84 // Pulls relevant data from the tick record
85 UE_API void GatherTickRecordData(const FAnimTickRecord& InTickRecord);
86
87 // Allows adding extra context data after GatherTickRecordData has been exectuted
88 template<typename Type, typename... TArgs>
89 void AddContextData(TArgs&&... Args)
90 {
91 static_assert(TPointerIsConvertibleFromTo<Type, const UE::Anim::IAnimNotifyEventContextDataInterface>::Value, "'Type' template parameter to MakeContextData must be derived from IAnimNotifyEventContextDataInterface");
92 if (!ContextData.IsValid())
93 {
95 }
96
97 ContextData->Add(MakeUnique<Type>(Forward<TArgs>(Args)...));
98 }
99
100 // Gets the source object of this notify (e.g. anim sequence), if any
102 {
103 return NotifySource;
104 }
105
106 // Gets the current animation's time that this notify was fired at
108 {
109 return CurrentAnimTime;
110 }
111
112 // Whether the context this notify was fired from is active or not (active == not blending out).
113 bool IsActiveContext() const
114 {
115 return bActiveContext;
116 }
117
118private:
119 // Context data gleaned from the tick record
121
122 const FAnimNotifyEvent* Notify = nullptr;
123
124 // If set, the Notify has been mirrored. The mirrored name can be found in MirrorTable->AnimNotifyToMirrorAnimNotifyMap
126 TObjectPtr<const UMirrorDataTable> MirrorTable = nullptr;
127
129 TObjectPtr<const UObject> NotifySource = nullptr;
130
131 // The recorded time from the tick record that this notify event was fired at
132 float CurrentAnimTime = 0.0f;
133
134 // Whether the context this notify was fired from is active or not (active == not blending out).
135 bool bActiveContext = false;
136};
137
138USTRUCT()
146
147USTRUCT()
158
159USTRUCT()
161{
163
165 : PredictedLODLevel(-1)
166 {
167 RandomStream.Initialize(0x05629063);
168 }
169
171 bool PassesFiltering(const FAnimNotifyEvent* Notify) const;
172
174 bool PassesChanceOfTriggering(const FAnimNotifyEvent* Event) const;
175
177 void AddAnimNotify(const FAnimNotifyEvent* Notify, const UObject* NotifySource);
178
180 UE_API void AddAnimNotifies(bool bSrcIsLeader, const TArray<FAnimNotifyEventReference>& NewNotifies, const float InstanceWeight);
181
183 void AddAnimNotifies(bool bSrcIsLeader, const TMap<FName, TArray<FAnimNotifyEventReference>>& NewNotifies, const float InstanceWeight);
184
188
190 void Reset(USkeletalMeshComponent* Component);
191
193 void Append(const FAnimNotifyQueue& Queue);
194
200
203
207
210 TMap<FName, FAnimNotifyArray> UnfilteredMontageAnimNotifies;
211
213 void ApplyMontageNotifies(const FAnimInstanceProxy& Proxy);
214private:
217
219 void AddAnimNotifiesToDestNoFiltering(const TArray<FAnimNotifyEventReference>& NewNotifies, TArray<FAnimNotifyEventReference>& DestArray) const;
220
223};
224
225#undef UE_API
#define UE_API
Definition AnimNotifyQueue.h:11
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
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define USTRUCT(...)
Definition ObjectMacros.h:746
Definition NameTypes.h:617
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition SharedPointer.h:692
Definition UniquePtr.h:107
Definition MirrorDataTable.h:102
Definition Object.h:95
Definition World.h:918
Definition AnimInstanceProxy.h:144
Definition AnimNotifyQueue.h:140
Definition AnimNotifyQueue.h:149
FAnimNotifyContext(const FAnimTickRecord &InTickRecord)
Definition AnimNotifyQueue.h:152
TArray< FAnimNotifyEventReference > ActiveNotifies
Definition AnimNotifyQueue.h:156
Definition AnimNotifyQueue.h:22
FAnimNotifyEventReference(const FAnimNotifyEvent *InNotify, const UObject *InNotifySource, const UMirrorDataTable *MirrorDataTable)
Definition AnimNotifyQueue.h:33
const Type * GetContextData() const
Definition AnimNotifyQueue.h:69
const FAnimNotifyEvent * GetNotify() const
Definition AnimNotifyQueue.h:40
const UMirrorDataTable * GetMirrorDataTable() const
Definition AnimNotifyQueue.h:53
bool IsActiveContext() const
Definition AnimNotifyQueue.h:113
float GetCurrentAnimationTime() const
Definition AnimNotifyQueue.h:107
void AddContextData(TArgs &&... Args)
Definition AnimNotifyQueue.h:89
friend bool operator==(const FAnimNotifyEventReference &Lhs, const FAnimNotifyEventReference &Rhs)
Definition AnimNotifyQueue.h:58
const UObject * GetSourceObject() const
Definition AnimNotifyQueue.h:101
void SetNotify(const FAnimNotifyEvent *InNotify)
Definition AnimNotifyQueue.h:45
Definition AnimTypes.h:277
Definition AnimNotifyQueue.h:161
int32 PredictedLODLevel
Definition AnimNotifyQueue.h:199
FRandomStream RandomStream
Definition AnimNotifyQueue.h:202
void AddAnimNotifies(const TMap< FName, TArray< FAnimNotifyEventReference > > &NewNotifies, const float InstanceWeight)
Definition AnimNotifyQueue.h:187
void AddAnimNotifies(const TArray< FAnimNotifyEventReference > &NewNotifies, const float InstanceWeight)
Definition AnimNotifyQueue.h:186
Definition AnimationAsset.h:411
Definition RandomStream.h:20
Definition ObjectPtr.h:488
Definition PointerIsConvertibleFromTo.h:60
Definition WeakObjectPtrTemplates.h:25