Multiple sphere collision response

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Multiple sphere collision response

Post by JP »

Hi dudes.

So I'm toying around with writing my own physics 'engine' and am currently working with spheres colliding with each other.

I found an articles which gives a seemingly great way of handling two spheres colliding with each other and correctly bouncing off each other.

But when more than two spheres collide with each other it all goes to heck and a handbasket and the spheres start intersecting with each other... floating like helium balloons and generally spazzin out bit time stylee...

Googling I have been unable to find any articles explaining how to do multiple sphere collision response... I have been told, and am finding myself, that it's a much much much bigger problem to solve when you add in extra spheres...

I'm surprised that there's nothing out there that I can find... Does anyone know of any articles that might help?

Here's the article that showed me how to do two spheres colliding: http://wp.freya.no/3d-math-and-physics/ ... -response/

Note that they have three spheres in their test app but they've engineered it so they never collide all at the same time... sneaky beggars!
Image Image Image
CuteAlien
Admin
Posts: 9651
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Maybe search for open-source billiard games. Those should implement such collisions. But purely guessing I suppose each sphere will have to add some force-vectors for each sphere against which they collide to find their final force-vector acting on them. This alone won't prevent collisions yet, but it should at least guarantee they are outside each other again within a few calculation steps. But maybe I'm too naive there :-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Yeah clearly there needs to be some accumulation of the resulting velocities from all the collisions but not sure how to calculate those... An industry expert in physics I spoke to said it's a crazy problem so I probably don't stand much hope!

But yeah, a billiards/snooker/pool game is a good idea to search for!
Image Image Image
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Right so after a bit of searching I found this likely candidate: http://foobillard.sourceforge.net/

open source in C for Linux and Windows. The code is horrific and I'm not convinced of their solution but it seems to do the trick well enough!
Image Image Image
Post Reply