Extending b2ContactListener in 2.1

I've just downloaded 2.1 and I'm completely lost on the new Contact Listener and the documentation hasn't caught up on the new system.

Before I would do this:

Code:
override public function Add(point:b2ContactPoint):void {
   add_list.push(new ContactPoint(point.shape1, point.shape2, point.separation, point.position.Copy(), point.normal.Copy()));
}


But b2ContactPoint and Add no longer exist.

And I need all of the information in there. I need both shapes, the contact point and the collision normal.

I'm assuming that I would override the new BeginContact method and try to extract data from the Contact object:

Code:
public virtual function BeginContact(contact:b2Contact):void { }


But how do I get my shapes, contact point and collision normal?
you might try the PreSolve event instead of BeginContact, seems like it might contain more info about the collision data, instead of just the contact pair.

im not too well versed on the new box2d yet, but thats where i would look.
You can override the BeginContact method in order to get the contact. From there you can pass in a new instance of b2WorldManifold to the GetWorldManifold method of the contact( see example below. ) The b2WorldManifold includes things like the normal and the collision points.

As for the shapes/bodies involved. The contact also has references to the two fixtures involved in the collision. Remember, in 2.1 shapes don't exist within the simulation on their own. They are attached to bodies by a fixture.

Code:
package 
{
   import Box2D.Collision.b2WorldManifold;
   import Box2D.Collision.Shapes.b2Shape;
   import Box2D.Common.Math.b2Vec2;
   import Box2D.Dynamics.b2Body;
   import Box2D.Dynamics.b2DefaultContactListener;
   import Box2D.Dynamics.b2Fixture;
   import Box2D.Dynamics.b2World;
   import Box2D.Dynamics.Contacts.b2Contact;
   
   public class CustomContactManager extends b2DefaultContactListener
   {
      
      public function CustomContactManager(world:b2World)
      {
         super(world);
         
      }
      
      override public function BeginContact(contact:b2Contact):void
      {
         super.BeginContact(contact);
         
         var mw:b2WorldManifold = contact.GetWorldManifold(mw);
         var firstPoint:b2Vec2 = mw.m_points[0];
         var normal:b2Vec2 = mw.m_normal;
         
         var fixture:b2Fixture = contact.GetFixtureA();
         var shape:b2Shape = fixture.GetShape();
         var body:b2Body = fixture.GetBody();
      }
      
      
   }

}
does the normal vector has length 1? or it has a length
according to impulse or velocity?
well i guess if it's called normal then it's length equals 1 🙂
I took a quick look through the code that generates m_Normal and it looks like it is in fact length 1. In the case of circles its being normalized and as a plane the transform.R matrix is being multiplied by the plane normal.
Looking deeper into the b2DefaulContactListener revealed what you need. The PostSolve method includes the impulse.

Original thread: https://box2d.org/forum/viewtopic.php?t=4668