I wouldn't mind using the colliders. It's just that you have to switch on shape types to use them, and construct a manifold. That would have doubled the size of the snippet I posted! I was really just suggesting a wrapper for that, (or maybe b2Distance); it's too much effort to write fractionally more efficient boolean tests, when in most efficiency cases, you'd be better off with a sensor.
In general, shapes are now a user type, so we can "talk about" them, but there is very little vocabulary to do so. I'd like to see the following general purpose additions so that next time someone asks why Box2D doesn't give an API for such and such, I can always fire off a quick snippet.
But now I'm just making demands again. But I've actually written the first two, and a bit of the third, before templates were really introduced to the C++.
Templated visitors are particularly neat, you can avoid the heap allocation usually required by polymorphism, which is otherwise a massive API problem considering Box2D doesn't return heap allocated values ever. But it seems that the API is still template free, even if they are used internally.
In general, shapes are now a user type, so we can "talk about" them, but there is very little vocabulary to do so. I'd like to see the following general purpose additions so that next time someone asks why Box2D doesn't give an API for such and such, I can always fire off a quick snippet.
- shape_cast<b2CircleShape*>, like dynamic_cast, except using shape GetType().
- Either virtual or templated unary/binary shape dispatch (e.g. exposing something like the contact register (virtual style) or taking a vistor object (see boost::variant for apply_visitor)
- More basic geometry queries, e.g. Support, b2Mul, Nearest. If you want even more: Flip, Scale, Furthest, AngularSupport, Bisect, Shrink, MinkowskiSum.
But now I'm just making demands again. But I've actually written the first two, and a bit of the third, before templates were really introduced to the C++.
Templated visitors are particularly neat, you can avoid the heap allocation usually required by polymorphism, which is otherwise a massive API problem considering Box2D doesn't return heap allocated values ever. But it seems that the API is still template free, even if they are used internally.