36 if(childNode->tag() ==
"Emitter") {
38 emitter->load(childNode);
39 m_emitters.push_back(emitter);
41 else if(childNode->tag().find(
"Affector") != std::string::npos) {
44 if(childNode->tag() ==
"GravityAffector")
46 else if(childNode->tag() ==
"AttractionAffector")
50 affector->load(childNode);
51 m_affectors.push_back(affector);
59 m_particles.push_back(particle);
64 for(
auto &particle: m_particles)
71 static const float delay = 0.0166;
75 if(elapsedTime < delay)
79 if(m_particles.empty() && m_emitters.empty()) {
84 m_lastUpdateTime =
g_clock.
seconds() - std::fmod(elapsedTime, delay);
86 auto self = static_self_cast<ParticleSystem>();
87 for(
int i = 0; i < std::floor(elapsedTime / delay); ++i) {
90 for(
auto it = m_emitters.begin(); it != m_emitters.end();) {
92 if(emitter->hasFinished()) {
93 it = m_emitters.erase(it);
95 emitter->update(delay,
self);
101 for(
auto it = m_affectors.begin(); it != m_affectors.end();) {
103 if(affector->hasFinished()) {
104 it = m_affectors.erase(it);
106 affector->update(delay);
112 for(
auto it = m_particles.begin(); it != m_particles.end();) {
114 if(particle->hasFinished()) {
115 it = m_particles.erase(it);
119 particleAffector->updateParticle(particle, delay);
121 particle->update(delay);