#include "irrlichttypes_extrabloated.h"
#include "client/tile.h"
#include "localplayer.h"
-#include "tileanimation.h"
+#include "../particles.h"
struct ClientEvent;
class ParticleManager;
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;
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;
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<float> 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;
};
/**
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<Particle*> m_particles;
- std::map<u32, ParticleSpawner*> m_particle_spawners;
+ 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;
std::mutex m_particle_list_lock;