Minetest  5.4.0
ParticleManager Class Reference

Class doing particle as well as their spawners handling. More...

#include <particles.h>

+ Collaboration diagram for ParticleManager:

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)
 
u64 generateSpawnerId ()
 This function is only used by client particle spawners. More...
 

Protected Member Functions

void addParticle (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)
 

Private Member Functions

void addParticleSpawner (u64 id, ParticleSpawner *toadd)
 
void deleteParticleSpawner (u64 id)
 
void stepParticles (float dtime)
 
void stepSpawners (float dtime)
 
void clearAll ()
 

Private Attributes

std::vector< Particle * > m_particles
 
std::unordered_map< u64, ParticleSpawner * > m_particle_spawners
 
u64 m_next_particle_spawner_id = U32_MAX + 1
 
ClientEnvironmentm_env
 
std::mutex m_particle_list_lock
 
std::mutex m_spawner_list_lock
 

Friends

class ParticleSpawner
 

Detailed Description

Class doing particle as well as their spawners handling.

Constructor & Destructor Documentation

◆ ParticleManager()

ParticleManager::ParticleManager ( ClientEnvironment env)

◆ ~ParticleManager()

ParticleManager::~ParticleManager ( )

References clearAll().

+ Here is the call graph for this function:

Member Function Documentation

◆ addDiggingParticles()

void ParticleManager::addDiggingParticles ( IGameDef gamedef,
LocalPlayer player,
v3s16  pos,
const MapNode n,
const ContentFeatures f 
)

References addNodeParticle(), ContentFeatures::drawtype, and NDT_AIRLIKE.

+ Here is the call graph for this function:

◆ addNodeParticle()

void ParticleManager::addNodeParticle ( IGameDef gamedef,
LocalPlayer player,
v3s16  pos,
const MapNode n,
const ContentFeatures f 
)

References addParticle(), BS, getNodeParticleParams(), m_env, Player::movement_gravity, p(), and LocalPlayer::physics_override_gravity.

Referenced by addDiggingParticles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addParticle()

void ParticleManager::addParticle ( Particle toadd)
protected

References m_particle_list_lock, and m_particles.

Referenced by addNodeParticle(), handleParticleEvent(), and ParticleSpawner::spawnParticle().

+ Here is the caller graph for this function:

◆ addParticleSpawner()

void ParticleManager::addParticleSpawner ( u64  id,
ParticleSpawner toadd 
)
private

References m_particle_spawners, and m_spawner_list_lock.

Referenced by handleParticleEvent().

+ Here is the caller graph for this function:

◆ clearAll()

void ParticleManager::clearAll ( )
private

References m_particle_list_lock, m_particle_spawners, m_particles, and m_spawner_list_lock.

Referenced by ~ParticleManager().

+ Here is the caller graph for this function:

◆ deleteParticleSpawner()

void ParticleManager::deleteParticleSpawner ( u64  id)
private

References m_particle_spawners, and m_spawner_list_lock.

Referenced by handleParticleEvent().

+ Here is the caller graph for this function:

◆ generateSpawnerId()

u64 ParticleManager::generateSpawnerId ( )
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)

Returns
new id

References m_next_particle_spawner_id.

Referenced by ModApiParticlesLocal::l_add_particlespawner().

+ Here is the caller graph for this function:

◆ getNodeParticleParams()

bool ParticleManager::getNodeParticleParams ( const MapNode n,
const ContentFeatures f,
ParticleParameters p,
video::ITexture **  texture,
v2f texpos,
v2f texsize,
video::SColor *  color,
u8  tilenum = 0 
)
staticprotected

References BS, TileLayer::color, ContentFeatures::drawtype, TileLayer::frames, MapNode::getColor(), TileLayer::has_color, TileSpec::layers, MATERIAL_FLAG_ANIMATION, TileLayer::material_flags, NDT_AIRLIKE, p(), TileLayer::scale, TAT_NONE, TileLayer::texture, and ContentFeatures::tiles.

Referenced by addNodeParticle(), handleParticleEvent(), and ParticleSpawner::spawnParticle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleParticleEvent()

void ParticleManager::handleParticleEvent ( ClientEvent event,
Client client,
LocalPlayer player 
)

◆ step()

void ParticleManager::step ( float  dtime)

References stepParticles(), and stepSpawners().

+ Here is the call graph for this function:

◆ stepParticles()

void ParticleManager::stepParticles ( float  dtime)
private

References m_particle_list_lock, and m_particles.

Referenced by step().

+ Here is the caller graph for this function:

◆ stepSpawners()

void ParticleManager::stepSpawners ( float  dtime)
private

References m_env, m_particle_spawners, and m_spawner_list_lock.

Referenced by step().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ ParticleSpawner

friend class ParticleSpawner
friend

Referenced by handleParticleEvent().

Member Data Documentation

◆ m_env

◆ m_next_particle_spawner_id

u64 ParticleManager::m_next_particle_spawner_id = U32_MAX + 1
private

Referenced by generateSpawnerId().

◆ m_particle_list_lock

std::mutex ParticleManager::m_particle_list_lock
private

◆ m_particle_spawners

std::unordered_map<u64, ParticleSpawner*> ParticleManager::m_particle_spawners
private

◆ m_particles

std::vector<Particle*> ParticleManager::m_particles
private

◆ m_spawner_list_lock

std::mutex ParticleManager::m_spawner_list_lock
private

The documentation for this class was generated from the following files: