Distinguish between collision surface orientations in box2d?

So, I feel a little awkward about answering my own question, but apparently it's officially encouraged.

So, I feel a little awkward about answering my own question, but apparently it's officially encouraged. Anyway, the problem with the way I was approaching things was twofold. Firstly, I was using the contact manifold's local normal instead of the world normal.

Secondly, my code for reversing the object transformations was buggy (I would never have needed to do this if I had been using the world manifold). The world manifold takes into account object transformations and sizes and as such contains data more easily applicable to the world co-ordinate system. By convention in Box2d, the collision normal (for both the world manifold and the contact manifold) points from A to B - this has to be taken into account for some uses, since the normal from A to B is the inverse of the normal from B to A, so you can't just assume that one body will always be A.So, the solution is to use get the world manifold for each collision, examine its normal, and then make whatever decisions you want to make.

For example, in the BeginContact method of a b2ContactListener subclass (if you have no idea what I'm talking about then check out part 2 of this tutorial): void ContactListener::BeginContact(b2Contact* contact) { b2WorldManifold wordManifold; contact->GetWorldManifold(&worldManifold); // this method calls b2WorldManifold::Initialize with the appropriate transforms and radii so you don't have to worry about that b2Vec2 worldNormal = worldManifold. Normal; // inspect it or do whatever you want based on that... } Since you'll likely need to check what bodies are colliding, and which one is A and which one is B, you may want to keep a vector of structs containing the fixtures that collided (as in that tutorial) and the normal, and iterate over the vector in your tick() method or similar.(You can get these out of the contact with contact->GetFixtureA() and contact->GetFixtureB().) Now, you could get the point data from the world manifold, and make your decisions based on that, but why would you when the normal is already available, since in this particular case the normal (combined with which shapes the normal points from and to) is all that is needed.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions