UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
WorldPSCPool.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"
7#include "WorldPSCPool.generated.h"
8
9class UParticleSystemComponent;
10class UParticleSystem;
11
12#define ENABLE_PSC_POOL_DEBUGGING (!UE_BUILD_SHIPPING)
13
14UENUM()
47
48USTRUCT()
50{
52
54 TObjectPtr<UParticleSystemComponent> PSC;
55
57
59 : PSC(nullptr), LastUsedTime(0.0f)
60 {
61
62 }
63 FPSCPoolElem(UParticleSystemComponent* InPSC, float InLastUsedTime)
65 {
66
67 }
68};
69
70
71USTRUCT()
73{
75
76 //Collection of all currently allocated, free items ready to be grabbed for use.
77 //TODO: Change this to a FIFO queue to get better usage. May need to make this whole class behave similar to TCircularQueue.
79 TArray<FPSCPoolElem> FreeElements;
80
81#if ENABLE_PSC_POOL_DEBUGGING
82 //Array of currently in flight components that will auto release.
84
85 //Array of currently in flight components that need manual release.
87
89 int32 MaxUsed = 0;
90#endif
91
92public:
93
94 void Cleanup();
95
97 UParticleSystemComponent* Acquire(UWorld* World, UParticleSystem* Template, EPSCPoolMethod PoolingMethod);
99 void Reclaim(UParticleSystemComponent* PSC, const float CurrentTimeSeconds);
100
102 void KillUnusedComponents(float KillTime, UParticleSystem* Template);
103
104 int32 NumComponents() { return FreeElements.Num(); }
105};
106
107USTRUCT()
109{
111
112private:
113 UPROPERTY()
114 TMap<TObjectPtr<UParticleSystem>, FPSCPool> WorldParticleSystemPools;
115
116 float LastParticleSytemPoolCleanTime;
117
119 float CachedWorldTime;
120public:
121
124
126
127 ENGINE_API UParticleSystemComponent* CreateWorldParticleSystem(UParticleSystem* Template, UWorld* World, EPSCPoolMethod PoolingMethod);
128
130 ENGINE_API void ReclaimWorldParticleSystem(UParticleSystemComponent* PSC);
131
133 ENGINE_API void Dump();
134};
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 UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
EPSCPoolMethod
Definition WorldPSCPool.h:16
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition ParticleSystem.h:160
Definition World.h:918
Definition WorldPSCPool.h:50
FPSCPoolElem(UParticleSystemComponent *InPSC, float InLastUsedTime)
Definition WorldPSCPool.h:63
Definition WorldPSCPool.h:73
int32 NumComponents()
Definition WorldPSCPool.h:104
TArray< TWeakObjectPtr< UParticleSystemComponent > > InUseComponents_Manual
Definition WorldPSCPool.h:86
TArray< TWeakObjectPtr< UParticleSystemComponent > > InUseComponents_Auto
Definition WorldPSCPool.h:83
Definition WorldPSCPool.h:109
Definition ObjectPtr.h:488