updraft function

void updraft(
  1. Particles ps,
  2. double dt, {
  3. double x = 0.0,
  4. double top = double.negativeInfinity,
  5. double w = 12.0,
  6. double up = 150.0,
  7. double squeeze = 4.0,
  8. double pull = 0.0,
  9. double low = 10.0,
  10. double reach = 100.0,
  11. double k = 1.0,
})

An updraft column at x: smoke, dust, fire and embers below top and within w of the axis are carried up (up px/s^2) and squeezed toward it.

Implementation

void updraft(
  Particles ps,
  double dt, {
  double x = 0.0,
  double top = double.negativeInfinity,
  double w = 12.0,
  double up = 150.0,
  double squeeze = 4.0,
  double pull = 0.0,
  double low = 10.0,
  double reach = 100.0,
  double k = 1.0,
}) {
  if (k <= 0.0) return;
  for (final q in ps.list) {
    if (q.delay > 0.0 || !_lifts.contains(q.k) || q.y < top) continue;
    final dx = q.x - x;
    final ax = dx.abs();
    final u = ax / w;
    if (u < 1.0) {
      final f = (1.0 - u * u) * k;
      q.vy -= up * f * dt;
      q.vx -= dx * squeeze * f * dt;
    }
    if (pull != 0.0 && q.y > -low && ax > w * 0.4 && ax < reach) {
      q.vx -= dx.sign * pull * k * (1.0 - ax / reach) * dt;
    }
  }
}