Advertisement

Box2d overview

Started by October 08, 2019 01:40 AM
2 comments, last by olivermarsh 5 years, 1 month ago

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.

 

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

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

This topic is closed to new replies.

Advertisement