getNeighbors method

void getNeighbors(
  1. Body particle,
  2. List<Body> neighbors
)

Get neighbors within smoothing volume, save in the array neighbors

Implementation

void getNeighbors(Body particle, List<Body> neighbors) {
  final N = particles.length;
  final id = particle.id;
  final r2 = smoothingRadius * smoothingRadius;
  final dist = _sphSystemGetNeighborsDist;
  for (int i = 0; i != N; i++) {
    final p = particles[i];
    p.position.vsub(particle.position, dist);
    if (id != p.id && dist.lengthSquared() < r2) {
      neighbors.add(p);
    }
  }
}