aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/particles/je_particle_pool.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/Graphics/particles/je_particle_pool.h')
-rw-r--r--src/libjin/Graphics/particles/je_particle_pool.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/libjin/Graphics/particles/je_particle_pool.h b/src/libjin/Graphics/particles/je_particle_pool.h
new file mode 100644
index 0000000..9bc7d78
--- /dev/null
+++ b/src/libjin/Graphics/particles/je_particle_pool.h
@@ -0,0 +1,56 @@
+#ifndef __JE_PARTICLE_BATCH_H
+#define __JE_PARTICLE_BATCH_H
+
+#include <list>
+
+#include "je_particle.h"
+
+namespace JinEngine
+{
+ namespace Graphics
+ {
+ namespace Particles
+ {
+
+ ///
+ /// Particle pool for reducing memory fragmentation.
+ ///
+ class ParticlePool
+ {
+ public:
+
+ ///
+ /// Particle pool constructor.
+ ///
+ /// @param count Max count of particles.
+ ///
+ ParticlePool(uint count);
+
+ ///
+ /// Particle pool destructor.
+ ///
+ ~ParticlePool();
+
+ ///
+ /// Claim a particle if available.
+ ///
+ Particle* claim();
+
+ ///
+ /// Recycle particle if the particle is no more alive.
+ ///
+ void recycle(Particle* particle);
+
+ private:
+ ///
+ /// All particles include available and inavailable particles.
+ ///
+ std::list<Particle> particles;
+
+ };
+
+ } // namespace Particles
+ } // namespace Graphics
+} // namespace JinEngine
+
+#endif \ No newline at end of file