Jump to content
  • Advertisement

Recommended Posts

Posted (edited)

Hi,  I was wanting to read the box2d source, but wanted to get a broad overview first.  I'll just say what I understand so far:

Box2d has discrete & continuous collision detection.  We first integrate our shapes velocity, and using a 'conservative advancement algorithm, we advance the shapes & find toi. 

It then uses gjk & barycentric coordinates to find the closest point on the shapes.  If  theyre overlapping we use epa or sat (and dont get a contact point? Or run gjk again?)

It then builds an incremental manifold (i probably have this wrong) adding a point each frame. 

Then once all collision points have been collected for the frame, they go through the collision solver that takes each collision, & adds an impulse to the shape to bring the relative velocity <= 0.  We go through the list of contacts several times (the iterative rigid body solver), to stabilise the simulation.  

I'm not sure what it uses for discrete collisions?

What things I don't understand is

1. When do we know we don't need a collision point anymore? When the collision points are moving away? 

2. How do we know a contact point is unique with gjk/barycentric coords? Or do we just add them and wait till they get pulled off the list?

3. If the toi is less than one & we want to use the rest up, do we run the whole collision routine again for a max say 4 times, to use it up, and where does this fit into the iterative solver? 

I kind of just want to get an overview of how a physics engine fits together and the parts or algorithms we need.   Its just for a hobby engine, and with understanding as a priority.  Any help would be great, and sorry if the question is a bit over simplified.

 

Edited by olivermarsh

Share this post


Link to post
Share on other sites
Advertisement
Posted (edited)

Box2D does not use incremental manifolds, but builds full manifolds each frame. The contact and friction impulses are matched between frames using contact IDs. 

Erin has given a bunch of talks over the year which cover certain aspects of Box2D in detail. You can find them all here:

https://box2d.org/downloads/

The problem you are looking at is covered in quite some detail in the presentations from 2007 - 2009. Also note that there is a simpler version called Box2D Lite which might be an easier entry into this topic. I have recommended in the past (and still do) to start from there if you want to start a small home project.

https://github.com/erincatto/box2d-lite

 

HTH,

-Dirk

Edited by Dirk Gregorius

Share this post


Link to post
Share on other sites
5 hours ago, Dirk Gregorius said:

Box2D does not use incremental manifolds, but builds full manifolds each frame. The contact and friction impulses are matched between frames using contact IDs. 

Erin has given a bunch of talks over the year which cover certain aspects of Box2D in detail. You can find them all here:

https://box2d.org/downloads/

The problem you are looking at is covered in quite some detail in the presentations from 2007 - 2009. Also note that there is a simpler version called Box2D Lite which might be an easier entry into this topic. I have recommended in the past (and still do) to start from there if you want to start a small home project.

https://github.com/erincatto/box2d-lite

 

HTH,

-Dirk

Thanks Dirk,  box2dlite is exactly what I needed. Thanks for your help, your presentations have been very helpful.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!