AntiCollision
AntiCollision copied to clipboard
Improve performance / precalculate positions
In the original c++ version balls start to miss each other almost immediately., but in js, it takes about a minute.
Due to the 60 fps requestAnimationFrame
cap, it's not so simple to make it that way.
Maybe moving calculations to a web worker or precalculating the positions would fix the issue.
Regarding performance, take a look at this engine https://github.com/artginzburg/AntiCollision/blob/main/src/modules/engine.ts. I don't know if you would want to merge with this fork since it is a bit different in terms of features.
But it is a lot faster. We can force the balls to reach stable state in less than a second (on Safari, at least). You can confirm this by visiting https://ginzburg.art/AntiCollision/ and holding the L key. The stats (like simulation speed) are shown on hover over the top-left edge of the screen.
@artginzburg wow, this is indeed a lot faster 🔥 I will analyze your code in depth when I will find some free time
I don't know if you would want to merge with this fork since it is a bit different in terms of features.
I can merge it if you want to. You did so much work that it feels like your fork is the main one now