• Advertisement
Sign in to follow this  

Physics Engine Basics

This topic is 2302 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I just bought real-time collision detection and should be here tomorrow. I have used newton game physics for years at a very minimal rate but I would like to work on my own physics possibly or at least read up on it. Any other recommendations, really I would be happy just learning collision response between a stack of boxes.

Share this post


Link to post
Share on other sites
Advertisement
Start with a simple 2D iterative impulsive simulation.

* Use euler integration.
* Use the Separating Axis Test to find the minimim axis of penetration between shapes. This will give you enough information for a contact point like this:

struct Contact
{
Vec3 Point;
Vec3 Normal;
float Depth;
};

* Iterate all of the contacts, applying an impulse between the bodies to keep the relative velocity constrained (along the normal and friction axes).


Then pile a lot of boxes up and watch it fail miserably.
You'd see that a single box on the ground jitters back and forth as it solves a contact to completion in one frame, and then detects the other the next frame.

When boxes stack up, the bottom ones are pushed through the world. Stacking is impossible.

* Add persistent contacts. As contacts are detected they are compared with previous contacts and if they match, the contact is updated. Contacts aren't removed until they separate by some margin.

With that the first box on the ground doesnt jitter quite as bad. Both contacts are solved each frame. But it's still not stable. Stacks still don't work.

* Add sequential impulses and temporal coherence. Everything gets 100 times stiffer.

Boxes smoothly come to rest on floor. Each box that stacks reacts as if the box below it is completely solid. Impulses are propagated through chains.

Then to make things practical you'll need a broad phase, continuous collision, sleeping, islands, multi-threading, collision callbacks/filtering, joints, vehicles, characters.

That should keep you busy for a while. The devil is in the details (performance, memory, leaks, ease of use, features, asset pipeline). Use lots of other physics engine as a guide. They're all pretty much the same.

Read this: http://graphics.cs.c...c/14/notesg.pdf

Share this post


Link to post
Share on other sites

I just bought real-time collision detection and should be here tomorrow. I have used newton game physics for years at a very minimal rate but I would like to work on my own physics possibly or at least read up on it. Any other recommendations, really I would be happy just learning collision response between a stack of boxes.


Stacks of boxes are about the most complex and difficult thing to solve in physics simulation full stop! :)

I would start learning at a more basic level...

I wrote these three tutorials which you might find useful which describe:

The basics of a physics engine, Collision detection and Advanced physics engine topics, in that order:

http://www.wildbunny.co.uk/blog/2011/04/06/physics-engines-for-dummies/
http://www.wildbunny.co.uk/blog/2011/04/20/collision-detection-for-dummies/
http://www.wildbunny.co.uk/blog/2011/06/07/how-to-make-angry-birds-part-2/

Cheers, Paul.

Share this post


Link to post
Share on other sites
I use Pauls speculative approach at the moment and it works wonderfully for bodes moving at any speed. It's also a neat trick to apply to other things that you want to arrive cleanly. It should be called, "the right way to clamp things."

The ghost collision side effect is very noticeable at high speed (100m/s, 30hz).

Share this post


Link to post
Share on other sites
Look at Erin Cattos presentation. They come with a simplified version of Box2D called Box2D Lite. Take this simple engine and port it to 3D. You will learn a lot from this and also have some orientation. If you feel more comfortable you can add more features later on. There is a lot of information out there and some stuff like the Baraff papers are really outdated since solving on the acceleration level can lead to infinite friction forces. This is what all the impulse stuff is about.

Share this post


Link to post
Share on other sites
Wildbunny's got some good stuff. I understand most of the concepts, majority of the collision methods, but its really just the response. Like this collided here and is moving, is every single rigid box that hits a plane, applying a torque from the center of mass and the point of collision? Is that how you always find the way to apply angular velocity/rotation? I'll go back and check that website in-depth.

Share this post


Link to post
Share on other sites
Impulses are propagated through chains.


Sounds very interesting. Could you please link to a ressource explaining this in further detail?

Cheers,
Mike

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement