Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Incrementally fix particle distances.
- for(auto i = 0; i < 20; i++) {
- foreach(j, p; taskPool.parallel(particles, numParticles/16)) {
- auto chg = vec2(0, 0);
- foreach(k, q; p.neighbors) {
- auto delta = q.pos - p.pos;
- auto dir = delta.normalize;
- auto mov = delta - dir * separation;
- chg += mov * 0.5;
- }
- changes[j] = chg;
- }
- foreach(j, chg; changes) {
- particles[j].pos += chg;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement