Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
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)
 
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 Particle *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
 
ClientEnvironmentm_env
 
IntervalLimiter m_buffer_gc
 
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(), ContentFeatures::alpha, ALPHAMODE_BLEND, BS, getNodeParticleParams(), PlayerPhysicsOverride::gravity, Player::movement_gravity, myrand_range(), p(), and Player::physics_override.

Referenced by addDiggingParticles().

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

◆ addParticle()

bool ParticleManager::addParticle ( std::unique_ptr< Particle > toadd)
protected

References getMaterialForParticle(), infostream, m_env, m_particle_buffers, m_particle_list_lock, and m_particles.

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

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

◆ addParticleSpawner()

void ParticleManager::addParticleSpawner ( u64 id,
std::unique_ptr< ParticleSpawner > toadd )
private

References errorstream, 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_dying_particle_spawners, m_particle_buffers, 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_dying_particle_spawners, 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.

◆ getMaterialForParticle()

video::SMaterial ParticleManager::getMaterialForParticle ( const Particle * texture)
staticprotected

References Particle::getBlendMode(), Particle::getTextureRef(), ClientParticleTexRef::ref, and setBlendMode().

Referenced by addParticle().

+ Here is the call graph for this function:
+ 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, 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().

+ 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 )

◆ reserveParticleSpace()

void ParticleManager::reserveParticleSpace ( size_t max_estimate)

References m_particle_list_lock, and m_particles.

Referenced by ParticleSpawner::ParticleSpawner().

+ Here is the caller graph for this function:

◆ step()

void ParticleManager::step ( float dtime)

References stepBuffers(), stepParticles(), and stepSpawners().

+ Here is the call graph for this function:

◆ stepBuffers()

void ParticleManager::stepBuffers ( float dtime)
private

References Profiler::avg(), g_profiler, m_buffer_gc, m_particle_buffers, m_particle_list_lock, and IntervalLimiter::step().

Referenced by step().

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

◆ stepParticles()

void ParticleManager::stepParticles ( float dtime)
private

References ParticleSpawner::decrActive(), ParticleSpawner::hasActive(), m_env, m_particle_list_lock, m_particles, and p().

Referenced by step().

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

◆ stepSpawners()

void ParticleManager::stepSpawners ( float dtime)
private

References m_dying_particle_spawners, m_env, m_particle_spawners, and m_spawner_list_lock.

Referenced by step().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ ParticleSpawner

friend class ParticleSpawner
friend

Member Data Documentation

◆ m_buffer_gc

IntervalLimiter ParticleManager::m_buffer_gc
private

Referenced by stepBuffers().

◆ m_dying_particle_spawners

std::vector<std::unique_ptr<ParticleSpawner> > ParticleManager::m_dying_particle_spawners
private

◆ m_env

◆ m_next_particle_spawner_id

u64 ParticleManager::m_next_particle_spawner_id = static_cast<u64>(U32_MAX) + 1
private

Referenced by generateSpawnerId().

◆ m_particle_buffers

std::vector<irr_ptr<ParticleBuffer> > ParticleManager::m_particle_buffers
private

Referenced by addParticle(), clearAll(), and stepBuffers().

◆ m_particle_list_lock

std::mutex ParticleManager::m_particle_list_lock
private

◆ m_particle_spawners

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

◆ m_particles

std::vector<std::unique_ptr<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: