aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Graphics/particle/je_particle_pool.h
blob: f1f62148587f8c13619ade843d182b5fa086b2eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#ifndef __JE_PARTICLE_BATCH_H
#define __JE_PARTICLE_BATCH_H

#include <list>

#include "je_particle.h"

namespace JinEngine
{
    namespace Graphics
    {

        ///
        /// 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 Graphics
} // namespace JinEngine

#endif