Lots of particles with Toxiclibs
in
Contributed Library Questions
•
1 year ago
Hi all,
I am using VerletPhysics from Toxiclibs to create a particle system. For each particle I use a spring that is attached to a fixed point (a locked particle), so that all particles are attracted to this point. At the same time I use a VerletMinDistanceSpring for all the particles to give the particles a minimum distance from each other. When I click the mouse, new particles are added, and the result works nicely and the particles are nicely stabilizing in a somewhat circular form around this target point. This is what I want to achieve.
However, it is not very effective to have a spring between all of the particles of course. I notice that at around 200 particles things start to slow down.
I have tried various things, like adding and removing springs if particles are a certain distance apart. Drawing to an offscreen buffer (PGraphics), etc.
But I haven't found a good solution to working with many particles this way yet. So, has anyone a good suggestion for a strategy for this situation? In short, I want to optimize my code by not having each particle have a spring connection to every other particle, while still make sure it has at least a spring connection to the target point, and also to the minimal required number of particles to maintain a 'force-directed layout'.
Thanks!
1