I think Box2d is missing a very important feature: allowing client code to opt out of collision responses based on contact point Add events. This feature would be necessary for both breakable objects (when the cannonball hits the window, we want to queue the destruction of the window and disable collision response so the cannonball doesn't bounce off) and Mario-style platforms (if entering the platform polygon from the top, it should be solid; if entering from another side, it should remain insubstantial until you leave it, allowing you to walk under it or jump up through it.)
I seem to have something working. I added a new member variable to b2Contact (m_disabled:Boolean) and modified b2World's Solve() to skip contacts which have m_disabled set when looping through bodies' contacts and adding them to islands. Finally, I exposed the b2Contact object to ContactListener.Add() (by passing it as a second parameter) so that my own contact listener can set m_disabled. Yes, there are probably cleaner ways to do this.
So far, I'm pleased with the results! I think I'll try out platforms and breakables shortly. If anyone's interested I can post a diff patch of my rather simple changes to the library. Maybe example swfs too?
Has anyone else attempted this? Care to share pitfalls or success stories?
I seem to have something working. I added a new member variable to b2Contact (m_disabled:Boolean) and modified b2World's Solve() to skip contacts which have m_disabled set when looping through bodies' contacts and adding them to islands. Finally, I exposed the b2Contact object to ContactListener.Add() (by passing it as a second parameter) so that my own contact listener can set m_disabled. Yes, there are probably cleaner ways to do this.
So far, I'm pleased with the results! I think I'll try out platforms and breakables shortly. If anyone's interested I can post a diff patch of my rather simple changes to the library. Maybe example swfs too?
Has anyone else attempted this? Care to share pitfalls or success stories?