AntiCollision icon indicating copy to clipboard operation
AntiCollision copied to clipboard

Improve performance / precalculate positions

Open KonradLinkowski opened this issue 2 years ago • 2 comments

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.

KonradLinkowski avatar Oct 05 '21 10:10 KonradLinkowski

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 avatar Dec 23 '22 06:12 artginzburg

@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

KonradLinkowski avatar Jan 01 '23 22:01 KonradLinkowski