UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AnimationStreaming.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3/*=============================================================================
4AnimationStreaming.h: Definitions of classes used for animation streaming.
5=============================================================================*/
6
7#pragma once
8
9#include "CoreMinimal.h"
12#include "Containers/Queue.h"
13#include "Stats/Stats.h"
14#include "ContentStreaming.h"
15#include "Async/AsyncWork.h"
17#include "Templates/Atomic.h"
18class UAnimStreamable;
20
21//
23{
25
28
31
33 : CompressedAnimData(nullptr)
34 , IORequest(nullptr)
35 , RequestStart(-1.0)
36 , Index(0)
38 {
39 }
40
42 {
43 checkf(CompressedAnimData == nullptr, TEXT("Animation chunk compressed data ptr not null (%p), Index: %u"), CompressedAnimData.Load(), Index);
44 }
45
46 void CleanUpIORequest();
47};
48
53{
56
57 // Frees streaming animation data resources, blocks pending async IO requests
58 void FreeResources();
59
66
74
83
88
95 bool BlockTillAllRequestsFinished(float TimeLimit = 0.0f);
96
97 // Return the number of bytes used
98 SIZE_T GetMemorySize() const;
99
100private:
101 // Don't allow copy construction as it could free shared memory
104
105 // Creates a new chunk, returns the chunk index
106 FLoadedAnimationChunk& AddNewLoadedChunk(uint32 ChunkIndex, FCompressedAnimSequence* ExistingData);
107 void FreeLoadedChunk(FLoadedAnimationChunk& LoadedChunk);
108 void ResetRequestedChunks();
109
110public:
113
114 /* Contains pointers to Chunks of animation data that have been streamed in */
116
118
121
123
125
128};
129
130
135{
138
140
141 // IStreamingManager interface
142 virtual void UpdateResourceStreaming( float DeltaTime, bool bProcessEverything=false ) override;
143 virtual int32 BlockTillAllRequestsFinished( float TimeLimit = 0.0f, bool bLogResults = false ) override;
144 virtual void CancelForcedResources() override;
145 virtual void NotifyLevelChange() override;
146 virtual void SetDisregardWorldResourcesForFrames( int32 NumFrames ) override;
147 virtual void AddLevel( class ULevel* Level ) override;
148 virtual void RemoveLevel( class ULevel* Level ) override;
149 virtual void NotifyLevelOffset( class ULevel* Level, const FVector& Offset ) override;
150 // End IStreamingManager interface
151
152 // IAnimationStreamingManager interface
153 virtual void AddStreamingAnim(UAnimStreamable* Anim) override;
154 virtual bool RemoveStreamingAnim(UAnimStreamable* Anim) override;
155 virtual SIZE_T GetMemorySizeForAnim(const UAnimStreamable* Anim) override;
156 virtual const FCompressedAnimSequence* GetLoadedChunk(const UAnimStreamable* Anim, uint32 ChunkIndex, bool bTrackAsRequested) const override;
157 // End IAnimationStreamingManager interface
158
161
162protected:
163
166
169};
#define checkf(expr, format,...)
Definition AssertionMacros.h:315
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::SIZE_T SIZE_T
An unsigned integer the same size as a pointer, the same as UPTRINT.
Definition Platform.h:1150
FPlatformTypes::int64 int64
A 64-bit signed integer.
Definition Platform.h:1127
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
UE::FPlatformRecursiveMutex FCriticalSection
Definition CriticalSection.h:53
uint32 Offset
Definition VulkanMemory.cpp:4033
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition BulkData.h:84
Definition Array.h:670
Definition Atomic.h:538
Definition UnrealString.h.inl:34
Definition AnimStreamable.h:91
Definition Level.h:423
@ false
Definition radaudio_common.h:23
U16 Index
Definition radfft.cpp:71
Definition AnimationStreaming.h:135
virtual void AddStreamingAnim(UAnimStreamable *Anim) override
Definition AnimationStreaming.cpp:466
virtual ~FAnimationStreamingManager()
Definition AnimationStreaming.cpp:328
virtual void CancelForcedResources() override
Definition AnimationStreaming.cpp:442
virtual SIZE_T GetMemorySizeForAnim(const UAnimStreamable *Anim) override
Definition AnimationStreaming.cpp:381
virtual void NotifyLevelChange() override
Definition AnimationStreaming.cpp:446
virtual void AddLevel(class ULevel *Level) override
Definition AnimationStreaming.cpp:454
virtual int32 BlockTillAllRequestsFinished(float TimeLimit=0.0f, bool bLogResults=false) override
Definition AnimationStreaming.cpp:408
virtual bool RemoveStreamingAnim(UAnimStreamable *Anim) override
Definition AnimationStreaming.cpp:484
FAnimationStreamingManager()
Definition AnimationStreaming.cpp:324
virtual void NotifyLevelOffset(class ULevel *Level, const FVector &Offset) override
Definition AnimationStreaming.cpp:462
virtual const FCompressedAnimSequence * GetLoadedChunk(const UAnimStreamable *Anim, uint32 ChunkIndex, bool bTrackAsRequested) const override
Definition AnimationStreaming.cpp:500
virtual void RemoveLevel(class ULevel *Level) override
Definition AnimationStreaming.cpp:458
TMap< UAnimStreamable *, FStreamingAnimationData * > StreamingAnimations
Definition AnimationStreaming.h:165
virtual void UpdateResourceStreaming(float DeltaTime, bool bProcessEverything=false) override
Definition AnimationStreaming.cpp:396
virtual void SetDisregardWorldResourcesForFrames(int32 NumFrames) override
Definition AnimationStreaming.cpp:450
FCriticalSection CriticalSection
Definition AnimationStreaming.h:168
void OnAsyncFileCallback(FStreamingAnimationData *StreamingAnimData, int32 ChunkIndex, int64 ReadSize, IBulkDataIORequest *ReadRequest, bool bWasCancelled)
Definition AnimationStreaming.cpp:332
Definition AnimCompressionTypes.h:775
Definition AnimationStreaming.h:23
FLoadedAnimationChunk()
Definition AnimationStreaming.h:32
void CleanUpIORequest()
Definition AnimationStreaming.cpp:24
double RequestStart
Definition AnimationStreaming.h:27
~FLoadedAnimationChunk()
Definition AnimationStreaming.h:41
class IBulkDataIORequest * IORequest
Definition AnimationStreaming.h:26
bool bOwnsCompressedData
Definition AnimationStreaming.h:30
uint32 Index
Definition AnimationStreaming.h:29
TAtomic< FCompressedAnimSequence * > CompressedAnimData
Definition AnimationStreaming.h:24
Definition AnimationStreaming.h:53
bool HasPendingRequests(TArray< uint32 > &IndicesToLoad, TArray< uint32 > &IndicesToFree) const
Definition AnimationStreaming.cpp:151
TArray< uint32 > LoadFailedChunks
Definition AnimationStreaming.h:124
void BeginPendingRequests(const TArray< uint32 > &IndicesToLoad, const TArray< uint32 > &IndicesToFree)
Definition AnimationStreaming.cpp:177
~FStreamingAnimationData()
Definition AnimationStreaming.cpp:45
TArray< uint32 > RequestedChunks
Definition AnimationStreaming.h:122
void FreeResources()
Definition AnimationStreaming.cpp:50
bool UpdateStreamingStatus()
Definition AnimationStreaming.cpp:94
FCriticalSection LoadedChunksCritcalSection
Definition AnimationStreaming.h:117
SIZE_T GetMemorySize() const
Definition AnimationStreaming.cpp:307
FAnimationStreamingManager * AnimationStreamingManager
Definition AnimationStreaming.h:127
TArray< FLoadedAnimationChunk > LoadedChunks
Definition AnimationStreaming.h:115
UAnimStreamable * StreamableAnim
Definition AnimationStreaming.h:112
bool BlockTillAllRequestsFinished(float TimeLimit=0.0f)
Definition AnimationStreaming.cpp:238
FStreamingAnimationData()
Definition AnimationStreaming.cpp:38
TArray< uint32 > LoadedChunkIndices
Definition AnimationStreaming.h:120
Definition ContentStreaming.h:640