Class doing particle as well as their spawners handling. More...
#include <particles.h>
Public Member Functions | |
ParticleManager (ClientEnvironment *env) | |
~ParticleManager () | |
void | step (float dtime) |
void | handleParticleEvent (ClientEvent *event, Client *client, LocalPlayer *player) |
void | addDiggingParticles (IGameDef *gamedef, LocalPlayer *player, v3s16 pos, const MapNode &n, const ContentFeatures &f) |
void | addNodeParticle (IGameDef *gamedef, LocalPlayer *player, v3s16 pos, const MapNode &n, const ContentFeatures &f) |
void | reserveParticleSpace (size_t max_estimate) |
u64 | generateSpawnerId () |
This function is only used by client particle spawners. | |
Protected Member Functions | |
bool | addParticle (std::unique_ptr< Particle > toadd) |
Static Protected Member Functions | |
static bool | getNodeParticleParams (const MapNode &n, const ContentFeatures &f, ParticleParameters &p, video::ITexture **texture, v2f &texpos, v2f &texsize, video::SColor *color, u8 tilenum=0) |
static video::SMaterial | getMaterialForParticle (const ClientParticleTexRef &texture) |
Private Member Functions | |
void | addParticleSpawner (u64 id, std::unique_ptr< ParticleSpawner > toadd) |
void | deleteParticleSpawner (u64 id) |
void | stepParticles (float dtime) |
void | stepSpawners (float dtime) |
void | stepBuffers (float dtime) |
void | clearAll () |
Private Attributes | |
std::vector< std::unique_ptr< Particle > > | m_particles |
std::unordered_map< u64, std::unique_ptr< ParticleSpawner > > | m_particle_spawners |
std::vector< std::unique_ptr< ParticleSpawner > > | m_dying_particle_spawners |
std::vector< irr_ptr< ParticleBuffer > > | m_particle_buffers |
u64 | m_next_particle_spawner_id = static_cast<u64>(U32_MAX) + 1 |
ClientEnvironment * | m_env |
IntervalLimiter | m_buffer_gc |
std::mutex | m_particle_list_lock |
std::mutex | m_spawner_list_lock |
Friends | |
class | ParticleSpawner |
Class doing particle as well as their spawners handling.
ParticleManager::ParticleManager | ( | ClientEnvironment * | env | ) |
ParticleManager::~ParticleManager | ( | ) |
void ParticleManager::addDiggingParticles | ( | IGameDef * | gamedef, |
LocalPlayer * | player, | ||
v3s16 | pos, | ||
const MapNode & | n, | ||
const ContentFeatures & | f ) |
References addNodeParticle(), ContentFeatures::drawtype, and NDT_AIRLIKE.
void ParticleManager::addNodeParticle | ( | IGameDef * | gamedef, |
LocalPlayer * | player, | ||
v3s16 | pos, | ||
const MapNode & | n, | ||
const ContentFeatures & | f ) |
References addParticle(), BS, getNodeParticleParams(), PlayerPhysicsOverride::gravity, Player::movement_gravity, myrand_range(), p(), and Player::physics_override.
Referenced by addDiggingParticles().
|
protected |
References getMaterialForParticle(), infostream, m_env, m_particle_buffers, m_particle_list_lock, and m_particles.
Referenced by addNodeParticle(), handleParticleEvent(), and ParticleSpawner::spawnParticle().
|
private |
References errorstream, m_particle_spawners, and m_spawner_list_lock.
Referenced by handleParticleEvent().
|
private |
References m_dying_particle_spawners, m_particle_buffers, m_particle_list_lock, m_particle_spawners, m_particles, and m_spawner_list_lock.
Referenced by ~ParticleManager().
|
private |
References m_dying_particle_spawners, m_particle_spawners, and m_spawner_list_lock.
Referenced by handleParticleEvent().
|
inline |
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)
References m_next_particle_spawner_id.
|
staticprotected |
References ParticleParamTypes::add, ParticleParamTypes::alpha, ParticleTexture::blendmode, ClientParticleTexRef::ref, ParticleParamTypes::screen, ParticleParamTypes::sub, and ClientParticleTexRef::tex.
Referenced by addParticle().
|
staticprotected |
References BS, TileLayer::color, ContentFeatures::drawtype, TileLayer::frames, MapNode::getColor(), TileLayer::has_color, MATERIAL_FLAG_ANIMATION, TileLayer::material_flags, myrand_range(), NDT_AIRLIKE, p(), TileLayer::scale, TAT_NONE, and TileLayer::texture.
Referenced by addNodeParticle(), handleParticleEvent(), and ParticleSpawner::spawnParticle().
void ParticleManager::handleParticleEvent | ( | ClientEvent * | event, |
Client * | client, | ||
LocalPlayer * | player ) |
References ClientEvent::add_particlespawner, addParticle(), addParticleSpawner(), ClientEvent::attached_id, CE_ADD_PARTICLESPAWNER, CE_DELETE_PARTICLESPAWNER, CE_SPAWN_PARTICLE, CONTENT_IGNORE, ClientEvent::delete_particlespawner, deleteParticleSpawner(), NodeDefManager::get(), ClientEnvironment::getGameDef(), getNodeParticleParams(), ClientEvent::id, m_env, IGameDef::ndef(), p(), ClientParticleTexRef::ref, and ClientEvent::type.
void ParticleManager::reserveParticleSpace | ( | size_t | max_estimate | ) |
References m_particle_list_lock, and m_particles.
Referenced by ParticleSpawner::ParticleSpawner().
void ParticleManager::step | ( | float | dtime | ) |
References stepBuffers(), stepParticles(), and stepSpawners().
|
private |
References Profiler::avg(), g_profiler, m_buffer_gc, m_particle_buffers, m_particle_list_lock, and IntervalLimiter::step().
Referenced by step().
|
private |
References ParticleSpawner::decrActive(), ParticleSpawner::hasActive(), m_env, m_particle_list_lock, m_particles, and p().
Referenced by step().
|
private |
References m_dying_particle_spawners, m_env, m_particle_spawners, and m_spawner_list_lock.
Referenced by step().
|
friend |
|
private |
Referenced by stepBuffers().
|
private |
Referenced by clearAll(), deleteParticleSpawner(), and stepSpawners().
|
private |
Referenced by addParticle(), handleParticleEvent(), ParticleSpawner::spawnParticle(), stepParticles(), and stepSpawners().
|
private |
Referenced by generateSpawnerId().
|
private |
Referenced by addParticle(), clearAll(), and stepBuffers().
|
private |
Referenced by addParticle(), clearAll(), reserveParticleSpace(), stepBuffers(), and stepParticles().
|
private |
Referenced by addParticleSpawner(), clearAll(), deleteParticleSpawner(), and stepSpawners().
|
private |
Referenced by addParticle(), clearAll(), reserveParticleSpace(), and stepParticles().
|
private |
Referenced by addParticleSpawner(), clearAll(), deleteParticleSpawner(), and stepSpawners().