void AttractionAffector::updateParticle(const ParticlePtr& particle, float elapsedTime) { if(!m_active) return; PointF pPosition = particle->getPosition(); PointF d = PointF(m_position.x - pPosition.x, pPosition.y - m_position.y); if(d.length() == 0) return; PointF direction = PointF(1, 1); if(m_repelish) direction = PointF(-1, -1); PointF pVelocity = particle->getVelocity() + (d / d.length() * m_acceleration * elapsedTime) * direction; particle->setVelocity(pVelocity - pVelocity * m_reduction/100.0 * elapsedTime); }