Lamp-Da 0.1
A compact lantern project
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
lampda::modes::ParticleSystem Class Reference

Define a particle system ALL PARTICLE SYSTEM SHARE THE SAME PÄRTICLE SUBSET. More...

#include <particle_system.hpp>

Public Member Functions

void reset ()
 reset system to zero count
 
void set_max_particle_count (const uint16_t _particleCount)
 Call when you want to change the particle count of the simulation Can be called once when starting the particle system.
 
void init_particules (const std::function< int16_t(size_t)> &positionGeneratorFunction)
 Init the particles from a initialization function.
 
void init_deferred_particules (uint8_t maxParticlesToPop, const std::function< int16_t(size_t)> &positionGeneratorFunction)
 Init the particles from a initialization function, in a timed defered way.
 
void iterate_no_collisions (const utils::vec3d &accelerationCartesian, const float deltaTime_s, const bool shouldContrain=true)
 Advance the particle simulation, ignoring collisions.
 
void iterate_with_collisions (const utils::vec3d &accelerationCartesian, const float deltaTime_s, const bool shouldContrain=true)
 Advance the particle simulation, taking collisions in account.
 
uint16_t depop_particules (const std::function< bool(const Particle &)> &shouldDepopFunction)
 Filter particles depending on condition.
 
uint16_t show (const std::function< uint32_t(int16_t, const Particle &)> sample_color, LampTy &lamp)
 Display this particle system.
 
uint16_t get_number_of_active () const
 Return the number of active particles.
 

Protected Member Functions

bool is_position_taken (const int16_t pos) const
 Return True if the position is already occupied.
 
void spawn_particule (const size_t index, const std::function< int16_t(size_t)> &positionGeneratorFunction)
 Spawn a particle.
 

Detailed Description

Define a particle system ALL PARTICLE SYSTEM SHARE THE SAME PÄRTICLE SUBSET.

Member Function Documentation

◆ depop_particules()

uint16_t lampda::modes::ParticleSystem::depop_particules ( const std::function< bool(const Particle &)> &  shouldDepopFunction)
inline

Filter particles depending on condition.

Parameters
[in]shouldDepopFunctionA function, that given a particle, will return true if it needs to be removed from the simulation.
Returns
The number of particles left in the simulation.

◆ init_deferred_particules()

void lampda::modes::ParticleSystem::init_deferred_particules ( uint8_t  maxParticlesToPop,
const std::function< int16_t(size_t)> &  positionGeneratorFunction 
)
inline

Init the particles from a initialization function, in a timed defered way.

Parameters
[in]maxParticlesToPopMaximum particles to spawn at this call
[in]positionGeneratorFunctionFunction that takes an index and return a led strip index

◆ init_particules()

void lampda::modes::ParticleSystem::init_particules ( const std::function< int16_t(size_t)> &  positionGeneratorFunction)
inline

Init the particles from a initialization function.

Parameters
[in]positionGeneratorFunctionFunction that takes an index and return a ledstrip index

◆ iterate_no_collisions()

void lampda::modes::ParticleSystem::iterate_no_collisions ( const utils::vec3d accelerationCartesian,
const float  deltaTime_s,
const bool  shouldContrain = true 
)
inline

Advance the particle simulation, ignoring collisions.

Parameters
[in]accelerationCartesian3d acceleration vector to apply to particles
[in]deltaTime_sTime since last update, in seconds
[in]shouldContrainIf true, will constrain the particles to the lamp body.

◆ iterate_with_collisions()

void lampda::modes::ParticleSystem::iterate_with_collisions ( const utils::vec3d accelerationCartesian,
const float  deltaTime_s,
const bool  shouldContrain = true 
)
inline

Advance the particle simulation, taking collisions in account.

Parameters
[in]accelerationCartesian3d acceleration vector to apply to particles
[in]deltaTime_sTime since last update, in seconds
[in]shouldContrainIf true, will constrain the particles to the lamp body.

◆ show()

uint16_t lampda::modes::ParticleSystem::show ( const std::function< uint32_t(int16_t, const Particle &)>  sample_color,
LampTy lamp 
)
inline

Display this particle system.

Parameters
[in]sample_colorsampling function for the particle color
[in,out]lampThe lamp object to write to

◆ spawn_particule()

void lampda::modes::ParticleSystem::spawn_particule ( const size_t  index,
const std::function< int16_t(size_t)> &  positionGeneratorFunction 
)
inlineprotected

Spawn a particle.

Parameters
[in]indexIndex of this particle
[in]positionGeneratorFunctionSpawn function

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