Plasma Engine  2.0
Loading...
Searching...
No Matches
ParticleSystemInstance.h
1#pragma once
2
3#include <Foundation/DataProcessing/Stream/ProcessingStream.h>
4#include <Foundation/DataProcessing/Stream/ProcessingStreamGroup.h>
5#include <Foundation/Math/BoundingBoxSphere.h>
6#include <Foundation/Math/Random.h>
7#include <ParticlePlugin/Declarations.h>
8#include <ParticlePlugin/Events/ParticleEvent.h>
9#include <ParticlePlugin/ParticlePluginDLL.h>
10
12
14class PL_PARTICLEPLUGIN_DLL plParticleSystemInstance
15{
16public:
18
19 void Construct(plUInt32 uiMaxParticles, plWorld* pWorld, plParticleEffectInstance* pOwnerEffect, float fSpawnCountMultiplier);
20 void Destruct();
21
22 bool IsVisible() const { return m_bVisible; }
23
24 void SetEmitterEnabled(bool bEnable) { m_bEmitterEnabled = bEnable; }
25 bool GetEmitterEnabled() const { return m_bEmitterEnabled; }
26
27 bool HasActiveParticles() const;
28
29 void ConfigureFromTemplate(const plParticleSystemDescriptor* pTemplate);
30 void Finalize();
31
32 void ReinitializeStreamProcessors(const plParticleSystemDescriptor* pTemplate);
33
34 void CreateStreamProcessors(const plParticleSystemDescriptor* pTemplate);
35
36 void SetupOptionalStreams();
37
38 void SetTransform(const plTransform& transform, const plVec3& vParticleStartVelocity);
39 const plTransform& GetTransform() const { return m_Transform; }
40 const plVec3& GetParticleStartVelocity() const { return m_vParticleStartVelocity; }
41
42 plParticleSystemState::Enum Update(const plTime& diff);
43
44 plWorld* GetWorld() const { return m_pWorld; }
45
46 plUInt64 GetMaxParticles() const { return m_StreamGroup.GetNumElements(); }
47 plUInt64 GetNumActiveParticles() const { return m_StreamGroup.GetNumActiveElements(); }
48
49
50
52 plProcessingStream* QueryStream(const char* szName, plProcessingStream::DataType type) const;
53
55 void CreateStream(const char* szName, plProcessingStream::DataType type, plProcessingStream** pStream, plParticleStreamBinding& ref_binding, bool bExpectInitializedValue);
56
57 void ProcessEventQueue(plParticleEventQueue queue);
58
59 plParticleEffectInstance* GetOwnerEffect() const { return m_pOwnerEffect; }
60 plParticleWorldModule* GetOwnerWorldModule() const;
61
62 void ExtractSystemRenderData(plMsgExtractRenderData& ref_msg, const plTransform& instanceTransform) const;
63
65
66 void AddParticleDeathEventHandler(ParticleDeathHandler handler);
67 void RemoveParticleDeathEventHandler(ParticleDeathHandler handler);
68
69 void SetBoundingVolume(const plBoundingBoxSphere& volume, float fMaxParticleSize);
70 const plBoundingBoxSphere& GetBoundingVolume() const { return m_BoundingVolume; }
71
72 bool IsContinuous() const;
73
74 float GetSpawnCountMultiplier() const { return m_fSpawnCountMultiplier; }
75
76private:
77 bool IsEmitterConfigEqual(const plParticleSystemDescriptor* pTemplate) const;
78 bool IsInitializerConfigEqual(const plParticleSystemDescriptor* pTemplate) const;
79 bool IsBehaviorConfigEqual(const plParticleSystemDescriptor* pTemplate) const;
80 bool IsTypeConfigEqual(const plParticleSystemDescriptor* pTemplate) const;
81 bool IsFinalizerConfigEqual(const plParticleSystemDescriptor* pTemplate) const;
82
83 void CreateStreamZeroInitializers();
84
90
91 bool m_bVisible; // typically used in editor to hide a system
92 bool m_bEmitterEnabled;
93 plParticleEffectInstance* m_pOwnerEffect;
94 plWorld* m_pWorld;
95 plTransform m_Transform;
96 plVec3 m_vParticleStartVelocity;
97 float m_fSpawnCountMultiplier = 1.0f;
98
99 plProcessingStreamGroup m_StreamGroup;
100
101 struct StreamInfo
102 {
103 plString m_sName;
104 bool m_bGetsInitialized = false;
105 bool m_bInUse = false;
106 plProcessingStreamProcessor* m_pDefaultInitializer = nullptr;
107 };
108
110
111 // culling data
112 plBoundingBoxSphere m_BoundingVolume;
113};
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
Definition Event.h:177
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
Definition ParticleEffectInstance.h:25
Definition Declarations.h:56
Definition ParticleSystemDescriptor.h:15
A particle system stores all data for one 'layer' of a running particle effect.
Definition ParticleSystemInstance.h:15
This world module stores all particle effect data that is active in a given plWorld instance.
Definition ParticleWorldModule.h:24
A stream group encapsulates the streams and the corresponding data processors.
Definition ProcessingStreamGroup.h:25
A single stream in a stream group holding contiguous data of a given type.
Definition ProcessingStream.h:8
DataType
The data types which can be stored in the stream. When adding new data types the GetDataTypeSize() of...
Definition ProcessingStream.h:13
Base class for all stream processor implementations.
Definition ProcessingStreamProcessor.h:11
A world encapsulates a scene graph of game objects and various component managers and their component...
Definition World.h:22
Definition RenderData.h:116
The time class encapsulates a double value storing the time in seconds.
Definition Time.h:12