diff options
| author | chai <chaifix@163.com> | 2018-10-29 08:27:51 +0800 |
|---|---|---|
| committer | chai <chaifix@163.com> | 2018-10-29 08:27:51 +0800 |
| commit | aca962d7ce3d404671cace2a82b04ff937375009 (patch) | |
| tree | ec315ef9df3dbd971bc914dae689e97cf9cf31ff /src/libjin/Graphics/particles/je_particle_pool.h | |
| parent | 297c78319e6bd891f27f9546334feedc030fc0a7 (diff) | |
*修改代码结构
Diffstat (limited to 'src/libjin/Graphics/particles/je_particle_pool.h')
| -rw-r--r-- | src/libjin/Graphics/particles/je_particle_pool.h | 56 |
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 |
