void ParticleField::updateParticles() { for (std::list<Particle>::iterator it = m_Particles.begin(); it != m_Particles.end(); it++) { ci::Vec4f curParticle = it->history.back(); if (curParticle[3] < HEAT_KILL_THRESHOLD) { it->history.pop_front(); continue; } if (inView(curParticle)) { curParticle[3] = std::min(static_cast<float>(curParticle[3] + HEAT_CHANGE_RATE), 1.0f); } else { curParticle[3] = std::max(static_cast<float>(curParticle[3] - HEAT_CHANGE_RATE), 0.0f); } ci::Vec3f vel; ci::Vec3f updatedLoc(curParticle[0], curParticle[1], curParticle[2]); getPerlin(updatedLoc, vel); updatedLoc += it->mult * vel * (m_CurTimeSeconds - m_LastTimeSeconds); applyForces(updatedLoc); curParticle[0] = updatedLoc[0]; curParticle[1] = updatedLoc[1]; curParticle[2] = updatedLoc[2]; it->history.push_back(curParticle); if (it->history.size() > MAX_HISTORY_LENGTH) { it->history.pop_front(); } } }
void Perlin2D::init_perlin(){ for (int i = 0; i < m_sizeX; ++i) for (int j = 0; j < m_sizeY; ++j) m_perlin.push_back(getPerlin(i, j)); }