I'm planning to use Box2D to create a game with only circle collisions. Hundreds of circles all changing sizes all the time.
Box 2D is not ideal because you can't resize fixtures. You have to remove them and recreate them. This is slow. Pooling is unlikely to work, because there will be hundreds of different sizes.
Is there an alternative physics engine that allows changing size of a circle collision object?
Comments
Open for suggestions on how to make this more efficient!
Here there is a sample on javascript
https://codepen.io/adrian_po_11235/pen/NqXyvq
Maybe you can take some ideas from there
In the case Box2D I had a similar problem than you (because I needed 700 circles per level ) so like @antix said you, you can make some sleep.. if these isn't on your screen for example like a google maps (if you're thinking multiplayer) only wake up circles those than you need show on your screen
[-] Liasoft
With my own prototype that used circles I used bump.lua. Each frame I would use queryRect() to get the circles in view and process those. Each time a circle left the screen I would start a counter and after 2 seconds it would go to sleep and not be processed if it did not come back onto the screen.
This worked pretty good and I was able to have many circles (thousands). Unfortunately I could never figure out how to stop circles clumping together.
And again there was the an issue when too many circles came onscreen
Box2D is pretty good at stopping overlapping objects, I suppose that's what a physics engine is for. As long as you don't create objects (fixtures) on top of each other you're pretty safe.
Too many circles on screen would be a problem, unless their behaviour were predictable and simple, in which case you could use PARTICLES!
But I love a bit of a hack, so may just try that!
https://deluxepixel.com
Likes: antix, pie, HubertRonald, MobAmuse
https://deluxepixel.com
Likes: SinisterSoft
https://deluxepixel.com
Likes: SinisterSoft, antix
The collision is pretty simple & fast though - that could be done inline with the main code to speed things up.
The x*x (square) is used quite a lot in my code. I'm sure we could add an new operator to Lua to do this really common operation - it would shave time off a lot of code all over the place as gideros wouldn't need to look up the variable twice - just once. Maybe this ^^var would work?
Maybe ^% could be used to give a very fast LUT based sqrt ?
so that would been to find a distance would be:
distance=^%(^^dx+^^dy)
Likes: antix, Apollo14
https://deluxepixel.com