diff options
author | Elias Fleckenstein <54945686+EliasFleckenstein03@users.noreply.github.com> | 2020-11-04 16:44:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-04 16:44:42 +0100 |
commit | 5d9ae5a91c544fc7fbd475decf47cef7e09ef8fc (patch) | |
tree | c980d614fec4a5495798be3e79e033229062c3cd /src/client/particles.h | |
parent | 28f6a79706b088c37268a59d90878220dc4ef9c7 (diff) | |
parent | 3af10766fd2b58b068e970266724d7eb10e9316b (diff) | |
download | dragonfireclient-5d9ae5a91c544fc7fbd475decf47cef7e09ef8fc.tar.xz |
Merge branch 'master' into master
Diffstat (limited to 'src/client/particles.h')
-rw-r--r-- | src/client/particles.h | 82 |
1 files changed, 29 insertions, 53 deletions
diff --git a/src/client/particles.h b/src/client/particles.h index 2011f0262..b3a1f1156 100644 --- a/src/client/particles.h +++ b/src/client/particles.h @@ -33,41 +33,24 @@ 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(); @@ -107,23 +90,19 @@ 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; @@ -140,21 +119,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 @@ -163,17 +142,14 @@ 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); @@ -184,13 +160,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; }; |