Jump to content

  • Log In with Google      Sign In   
  • Create Account


Physics Engine Basics


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 dpadam450   Members   -  Reputation: 862

Like
0Likes
Like

Posted 01 November 2011 - 12:38 AM

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.

Sponsor:

#2 bzroom   Members   -  Reputation: 646

Like
0Likes
Like

Posted 01 November 2011 - 01:37 AM

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

#3 wildbunny   Members   -  Reputation: 550

Like
2Likes
Like

Posted 01 November 2011 - 03:17 AM

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.

#4 bzroom   Members   -  Reputation: 646

Like
0Likes
Like

Posted 01 November 2011 - 03:30 AM

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).

#5 Dirk Gregorius   Members   -  Reputation: 733

Like
0Likes
Like

Posted 01 November 2011 - 12:18 PM

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.

#6 dpadam450   Members   -  Reputation: 862

Like
0Likes
Like

Posted 01 November 2011 - 11:33 PM

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.

#7 h4tt3n   Members   -  Reputation: 997

Like
0Likes
Like

Posted 03 November 2011 - 01:03 PM

Impulses are propagated through chains.


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

Cheers,
Mike




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS