Big Changes - Read Before Updating

News about Box2D
Erin Catto
Site Admin
Posts: 2948
Joined: Thu Sep 06, 2007 12:34 am

Big Changes - Read Before Updating

Postby Erin Catto » Thu May 28, 2009 12:23 am

- Added b2Fixture. Shapes are no longer directly tied to bodies. Instead you create a fixture with a fixture definition. This creates a fixture that binds a shape to a body. Shapes can now be created without bodies and can be used in low level collision routines, indepedent of the physics system.
- Shapes no longer have a core (shrunken shape) for continuous physics. Instead every shape now has a radius. For circles this is the regular circle radius. For edge and polygon shapes, the radius is the skin thickness. The effect of this is you will see a small gap between shapes (except circle vs circle).
- Changed the way edge chains are created. Use b2CreateEdgeChain.
- Improved GJK algorithm. Implemented simplex warm starting.

===========

The documentation is now out of date. Please see the examples for current usage. All examples should work.

I hope you find these changes useful. More is to come over the next few weeks.

Please reply here if you have questions about these changes.

Neosano
Posts: 177
Joined: Fri Jan 23, 2009 12:53 pm

Re: Big Changes - Read Before Updating

Postby Neosano » Thu May 28, 2009 7:08 am

Hmm, I think it'll be hard to port things for this... But it's really cool! Good job!

Erin Catto
Site Admin
Posts: 2948
Joined: Thu Sep 06, 2007 12:34 am

Re: Big Changes - Read Before Updating

Postby Erin Catto » Thu May 28, 2009 9:54 am

I wouldn't do any porting yet. There are more big changes coming soon. In particular, we are working on a new broad-phase.

xdimka
Posts: 7
Joined: Tue Jan 20, 2009 4:57 pm

Re: Big Changes - Read Before Updating

Postby xdimka » Thu May 28, 2009 2:16 pm

good work)

P.S.
rename SetMassFromShapes -> SetMassFromFixtures()

BorisTheBrave
Posts: 1911
Joined: Mon Jan 07, 2008 10:51 am
Contact:

Re: Big Changes - Read Before Updating

Postby BorisTheBrave » Thu May 28, 2009 2:33 pm

Sounds cool. I haven't had a chance to look take a good look at the code yet, through. There's quite a few API goofs like SetMassFromShapes, but that's ok, we'll smooth it out. We've got to put in some extra calls to take advantage of the restructuring, anyway.

But why the change in core shapes? I always preferred Box2D's way to Bullets, precisely because it doesn't leave these thin gaps lying around, or be inconsistent between circles and non circles.

Also, it's great to see the geometric properties of a shape separated from the body-related ones. But how do you create shapes? Are the public m_ variables going to become accessors shortly. Why aren't the definitions of shapes separated from the definition of fixtures, like how shapes and fixtures are seperate?

Erin Catto
Site Admin
Posts: 2948
Joined: Thu Sep 06, 2007 12:34 am

Re: Big Changes - Read Before Updating

Postby Erin Catto » Thu May 28, 2009 5:07 pm

A couple reasons to get rid of core shapes:
- reduces memory usage
- reduces code complexity
- removes assertions when creating slender shapes

Viewing circles as points with a radius reduces code complexity and improves performance. If you look over the new distance and time of impact code, you can see it uses templates so that no virtual functions are called in the inner loops. Having all shapes have a radius keeps this code cleaner.

The default polygon radius is 1cm. In the testbed the gap is usually quite small. In many cases the collision geometry only approximates the render geometry, so I believe this is the better trade-off.

You can create shapes on the stack or the heap now when doing raw collision computations. There are no factories for shapes because you cannot add shapes directly to b2World. Hence there are no definitions for shapes. Some shapes have helper functions to initialize them, some do not. Shapes are supposed to be fully public now because they have been simplified a lot and have little external dependencies. Shapes will not be normally used by Box2D users and are there as a low level utility for power users.

Villane
Posts: 101
Joined: Mon Sep 01, 2008 6:32 am

Re: Big Changes - Read Before Updating

Postby Villane » Mon Jun 01, 2009 1:52 pm

Nice. Reducing the dependencies of shapes was something I wanted to do with ScalaBox2D, but didn't have time to work out all the details. Will update the port when these changes have stabilized.

Erin Catto
Site Admin
Posts: 2948
Joined: Thu Sep 06, 2007 12:34 am

Re: Big Changes - Read Before Updating

Postby Erin Catto » Thu Jun 04, 2009 10:25 am

I have submitted some more changes that will likely break your contact listeners. Please see the testbed for example usage. We are working to fill out the testing on the new listener.

Villane
Posts: 101
Joined: Mon Sep 01, 2008 6:32 am

Re: Big Changes - Read Before Updating

Postby Villane » Mon Jun 08, 2009 3:50 pm

I have ported Fixtures already for Scala. I should probably hold off porting the other stuff if there are still going to be many changes?

dc443
Posts: 341
Joined: Fri May 16, 2008 10:09 am

Re: Big Changes - Read Before Updating

Postby dc443 » Sat Jul 11, 2009 11:54 pm

So as I understand it, fixtures use the "old" b2shapeDefs (i.e. create a fixture w/ a shapeDef ptr) to attach shapes onto bodies, and internally use shapes. If I need to do operations specific to what shape a fixture binds to a body, is this the standard way to do it? ((shapeType)fixture->getShape())->whatever

Also I don't think i understand what it means for a polygon to have a radius. And what is skin thickness?

Thanks


Return to “News”



Who is online

Users browsing this forum: No registered users and 1 guest