X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fclient%2Fparticles.h;h=2011f02626249071dee3a57adb4a47bb49428ef3;hb=542df11bed89ebad786220f1162597353ecc277d;hp=3392e7e950ae9a860d2b39420f817840c713236f;hpb=5f1cd555cd9d1c64426e173b30b5b792d211c835;p=dragonfireclient.git diff --git a/src/client/particles.h b/src/client/particles.h index 3392e7e95..2011f0262 100644 --- a/src/client/particles.h +++ b/src/client/particles.h @@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "irrlichttypes_extrabloated.h" #include "client/tile.h" #include "localplayer.h" -#include "tileanimation.h" +#include "../particles.h" struct ClientEvent; class ParticleManager; @@ -38,21 +38,11 @@ class Particle : public scene::ISceneNode IGameDef* gamedef, LocalPlayer *player, ClientEnvironment *env, - v3f pos, - v3f velocity, - v3f acceleration, - float expirationtime, - float size, - bool collisiondetection, - bool collision_removal, - bool object_collision, - bool vertical, + const ParticleParameters &p, video::ITexture *texture, v2f texpos, v2f texsize, - const struct TileAnimationParams &anim, - u8 glow, - video::SColor color = video::SColor(0xFFFFFFFF) + video::SColor color ); ~Particle() = default; @@ -119,21 +109,9 @@ class ParticleSpawner public: ParticleSpawner(IGameDef* gamedef, LocalPlayer *player, - u16 amount, - float time, - v3f minp, v3f maxp, - v3f minvel, v3f maxvel, - v3f minacc, v3f maxacc, - float minexptime, float maxexptime, - float minsize, float maxsize, - bool collisiondetection, - bool collision_removal, - bool object_collision, + const ParticleSpawnerParameters &p, u16 attached_id, - bool vertical, video::ITexture *texture, - u32 id, - const struct TileAnimationParams &anim, u8 glow, ParticleManager* p_manager); ~ParticleSpawner() = default; @@ -141,38 +119,20 @@ class ParticleSpawner void step(float dtime, ClientEnvironment *env); bool get_expired () - { return (m_amount <= 0) && m_spawntime != 0; } + { return p.amount <= 0 && p.time != 0; } private: void spawnParticle(ClientEnvironment *env, float radius, - bool is_attached, const v3f &attached_pos, - float attached_yaw); + const core::matrix4 *attached_absolute_pos_rot_matrix); ParticleManager *m_particlemanager; float m_time; IGameDef *m_gamedef; LocalPlayer *m_player; - u16 m_amount; - float m_spawntime; - v3f m_minpos; - v3f m_maxpos; - v3f m_minvel; - v3f m_maxvel; - v3f m_minacc; - v3f m_maxacc; - float m_minexptime; - float m_maxexptime; - float m_minsize; - float m_maxsize; + ParticleSpawnerParameters p; video::ITexture *m_texture; std::vector m_spawntimes; - bool m_collisiondetection; - bool m_collision_removal; - bool m_object_collision; - bool m_vertical; u16 m_attached_id; - struct TileAnimationParams m_animation; - u8 m_glow; }; /** @@ -196,26 +156,39 @@ friend class ParticleSpawner; void addNodeParticle(IGameDef *gamedef, LocalPlayer *player, v3s16 pos, const MapNode &n, const ContentFeatures &f); - u32 getSpawnerId() const + /** + * This function is only used by client particle spawners + * + * We don't need to check the particle spawner list because client ID will + * never overlap (u64) + * @return new id + */ + u64 generateSpawnerId() { - for (u32 id = 0;; ++id) { // look for unused particlespawner id - if (m_particle_spawners.find(id) == m_particle_spawners.end()) - return id; - } + 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); + void addParticle(Particle* toadd); private: + void addParticleSpawner(u64 id, ParticleSpawner *toadd); + void deleteParticleSpawner(u64 id); - void stepParticles (float dtime); - void stepSpawners (float dtime); + void stepParticles(float dtime); + void stepSpawners(float dtime); - void clearAll (); + void clearAll(); std::vector m_particles; - std::map m_particle_spawners; + std::unordered_map 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; std::mutex m_particle_list_lock;