Particles with collision physics?

Official forum for the Chipmunk2D Physics Library.
Post Reply
jessegrosjean
Posts: 1
Joined: Thu Jan 16, 2014 9:56 am
Contact:

Particles with collision physics?

Post by jessegrosjean »

I want to make a "game" on my iPad so that my kids can play with gravity, learn about orbits, etc.

My idea for doing this is to just initially fill the space with a bunch of uniform sized (pretty small) circle particles. The space will have no global gravity force, but I'll calculate an n-body gravity using a barns-hut algorithm. If you just let the system go all the particles will pull towards each other and form a big ball (planet). Or with some interaction forces you would be able to pull off some particles and that would make a moon orbiting around the planet, etc. I think generally the more particles that I can simulate in this way the more interesting it will be.

Right now I'm at the stage where I've got my particles pulling towards each other using a barns-hut algorithm. But I have no collision detection, and so they just pass through each other instead of colliding, and so no planet body ever emerges.

So for the next step I think I need some sort of physics engine, to detect and process the collision physics, and that's why I'm looking at Chipmunk2d. I have two questions:

1. On a current release iPad does anyone have a ballpark idea of how many particles chipmunk2d could handle in this case. (small, circles, colliding, non rotating)?

2. Giving the above constraints do you think using chipmunk2d is the right approach? And if not can you give me pointers to another engine more optimized for the case that I describe?

Thanks,
Jesse
FlyingAvatar
Posts: 2
Joined: Sun Jan 19, 2014 10:23 pm
Contact:

Re: Particles with collision physics?

Post by FlyingAvatar »

Coincidentally, I have done nearly exactly this. You should have no problem with several hundred particles, perhaps a couple thousand. My simulation iterated (not using Barns-Hut) through the particles before each physics tick and calculated the gravitational force to apply to each other particle.

If I recall correctly, the computational overhead of all the collisions will dwarf the gravitational calculations, so using Barns-Hut may be of limited benefit, but I am curious to hear your results.
Post Reply

Who is online

Users browsing this forum: No registered users and 30 guests