- 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.
Hmm, I think it'll be hard to port things for this... But it's really cool! Good job!
I wouldn't do any porting yet. There are more big changes coming soon. In particular, we are working on a new broad-phase.
good work)
P.S.
rename SetMassFromShapes -> SetMassFromFixtures()
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?
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.
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.
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.
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?
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