🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

What are the physics algorithms used in this?

Started by
6 comments, last by quasar3d 6 years ago

For a strategy game, I want to replace my rectangle collision detection by the type of physics displayed in the following video. I'm looking for sources to learn how to implement this. The video description states that it could handle 20k units on an old pc, how accurate is that statement? Would a physics engine like bullet be able to handle 20k circles like that?

 

Advertisement

Not sure.

But if all you need is what's shown in the video, then I'd say using a full-blown physics engine is an overkill. You probably don't need things like friction, restitution, torque, etc.

I'd say all you need is a decent broadphase and specialized circle-vs-circle collision resolution (or peer avoidance steering behavior, which can be somewhat similar in implementation in this particular case).

Edit: Maaaaybe also consider islanding if you need to parallelize processing of disjoint groups. I think that's more than enough in this use case.

Ming-Lun "Allen" Chou

Physics / Graphics / Procedural Animation
http://allenchou.net

On 5/16/2018 at 9:34 AM, Michael Aganier said:

For a strategy game, I want to replace my rectangle collision detection by the type of physics displayed in the following video. I'm looking for sources to learn how to implement this. The video description states that it could handle 20k units on an old pc, how accurate is that statement? Would a physics engine like bullet be able to handle 20k circles like that?

 

I dont think Bullet could handle 20k such units, although of course it matters what exactly is an "old pc".  However the physics there is fairly simple and I think an optimized engine that just handles that and not anything fancier could be made to deal with that many units, especially if it can be threaded.

I reckon you could just do it as a DX9 render texture. If you're allowed to do DX10 the sampling will be a bit easier. Note the particle would be bigger than a single texel but you just sample an area and use breach of radius to calculate compression. So you have a vector map which looks like a normal texture used in bump mapping and a particle map. Alternate between rendering particle position and generating the vector map. The vector map rendering would be say 16 to 256 passes to add neighbouring forces, ie transferring forces of particles being compressed. You just add vectors together so each vector would only be small so they add up to less than 1. Then a single pass to move a particle based on the force map. I'm not a mobile dev but even an old Windows PC should be ok doing that.

 

On 5/16/2018 at 7:34 PM, Michael Aganier said:

The video description states that it could handle 20k units on an old pc, how accurate is that statement?

I guess PC that handled 20k circles has run under windows-95.

Algo looks to be very simple. When circles of same color comes closer then tolerance distance algo join it to net. Joints works like springs with limited minimal distance betwin them and limited distance for break joint. So each circle connected to network exactly know his neiborghud that require to check distance and calculate response. Also border circles of network marked, so to check contact of two groups or  not joined circle and group enougt to check contacts for border circles only.  Collision detection for 2 circles is faster possible collision detection ever -it require just to calculate square distance betwin 2 points.

#define if(a) if((a) && rand()%100)

Looking at the video again I noticed just how jittery the balls are while colliding with others around them.  Something like Bullet would definitely do a better job and you would not get that kind of jitter.

"Reciprocal velocity obstacles" might be what you're looking for.

This topic is closed to new replies.

Advertisement