diff options
Diffstat (limited to 'src/client/particles.h')
-rw-r--r-- | src/client/particles.h | 82 |
1 files changed, 53 insertions, 29 deletions
diff --git a/src/client/particles.h b/src/client/particles.h index b3a1f1156..2011f0262 100644 --- a/src/client/particles.h +++ b/src/client/particles.h @@ -33,24 +33,41 @@ struct ContentFeatures; class Particle : public scene::ISceneNode { -public: - Particle(IGameDef *gamedef, LocalPlayer *player, ClientEnvironment *env, - const ParticleParameters &p, video::ITexture *texture, v2f texpos, - v2f texsize, video::SColor color); + public: + Particle( + IGameDef* gamedef, + LocalPlayer *player, + ClientEnvironment *env, + const ParticleParameters &p, + video::ITexture *texture, + v2f texpos, + v2f texsize, + video::SColor color + ); ~Particle() = default; - virtual const aabb3f &getBoundingBox() const { return m_box; } + virtual const aabb3f &getBoundingBox() const + { + return m_box; + } - virtual u32 getMaterialCount() const { return 1; } + virtual u32 getMaterialCount() const + { + return 1; + } - virtual video::SMaterial &getMaterial(u32 i) { return m_material; } + virtual video::SMaterial& getMaterial(u32 i) + { + return m_material; + } virtual void OnRegisterSceneNode(); virtual void render(); void step(float dtime); - bool get_expired() { return m_expiration < m_time; } + bool get_expired () + { return m_expiration < m_time; } private: void updateLight(); @@ -90,19 +107,23 @@ private: class ParticleSpawner { public: - ParticleSpawner(IGameDef *gamedef, LocalPlayer *player, - const ParticleSpawnerParameters &p, u16 attached_id, - video::ITexture *texture, ParticleManager *p_manager); + ParticleSpawner(IGameDef* gamedef, + LocalPlayer *player, + const ParticleSpawnerParameters &p, + u16 attached_id, + video::ITexture *texture, + ParticleManager* p_manager); ~ParticleSpawner() = default; void step(float dtime, ClientEnvironment *env); - bool get_expired() { return p.amount <= 0 && p.time != 0; } + bool get_expired () + { return p.amount <= 0 && p.time != 0; } private: void spawnParticle(ClientEnvironment *env, float radius, - const core::matrix4 *attached_absolute_pos_rot_matrix); + const core::matrix4 *attached_absolute_pos_rot_matrix); ParticleManager *m_particlemanager; float m_time; @@ -119,21 +140,21 @@ private: */ class ParticleManager { - friend class ParticleSpawner; - +friend class ParticleSpawner; public: - ParticleManager(ClientEnvironment *env); + ParticleManager(ClientEnvironment* env); ~ParticleManager(); - void step(float dtime); + void step (float dtime); - void handleParticleEvent(ClientEvent *event, Client *client, LocalPlayer *player); + void handleParticleEvent(ClientEvent *event, Client *client, + LocalPlayer *player); void addDiggingParticles(IGameDef *gamedef, LocalPlayer *player, v3s16 pos, - const MapNode &n, const ContentFeatures &f); + const MapNode &n, const ContentFeatures &f); void addNodeParticle(IGameDef *gamedef, LocalPlayer *player, v3s16 pos, - const MapNode &n, const ContentFeatures &f); + const MapNode &n, const ContentFeatures &f); /** * This function is only used by client particle spawners @@ -142,14 +163,17 @@ public: * never overlap (u64) * @return new id */ - u64 generateSpawnerId() { return m_next_particle_spawner_id++; } + u64 generateSpawnerId() + { + return m_next_particle_spawner_id++; + } protected: static bool getNodeParticleParams(const MapNode &n, const ContentFeatures &f, - ParticleParameters &p, video::ITexture **texture, v2f &texpos, - v2f &texsize, video::SColor *color, u8 tilenum = 0); + ParticleParameters &p, video::ITexture **texture, v2f &texpos, + v2f &texsize, video::SColor *color, u8 tilenum = 0); - void addParticle(Particle *toadd); + void addParticle(Particle* toadd); private: void addParticleSpawner(u64 id, ParticleSpawner *toadd); @@ -160,13 +184,13 @@ private: void clearAll(); - std::vector<Particle *> m_particles; - std::unordered_map<u64, ParticleSpawner *> m_particle_spawners; - // Start the particle spawner ids generated from here after u32_max. lower values - // are for server sent spawners. + std::vector<Particle*> m_particles; + std::unordered_map<u64, ParticleSpawner*> m_particle_spawners; + // Start the particle spawner ids generated from here after u32_max. lower values are + // for server sent spawners. u64 m_next_particle_spawner_id = U32_MAX + 1; - ClientEnvironment *m_env; + ClientEnvironment* m_env; std::mutex m_particle_list_lock; std::mutex m_spawner_list_lock; }; |