Dart Documentationbox2dPolygonAndCircleContact

PolygonAndCircleContact class

class PolygonAndCircleContact extends Contact {

 PolygonAndCircleContact(DefaultWorldPool argPool) :
   super(argPool) { }

 void init(Fixture fA, Fixture fB) {
   Expect.equals(ShapeType.POLYGON, fA.type);
   Expect.equals(ShapeType.CIRCLE, fB.type);
   super.init(fA, fB);
 }

 void evaluate(Manifold argManifold, Transform xfA, Transform xfB) {
   pool.collision.collidePolygonAndCircle(argManifold, fixtureA.shape,
       xfA, fixtureB.shape, xfB);
 }
}

Extends

Contact > PolygonAndCircleContact

Constructors

new PolygonAndCircleContact(DefaultWorldPool argPool) #

PolygonAndCircleContact(DefaultWorldPool argPool) :
 super(argPool) { }

Properties

ContactEdge edge1 #

inherited from Contact

Nodes for connecting bodies.

ContactEdge edge1;

ContactEdge edge2 #

inherited from Contact
ContactEdge edge2;

bool enabled #

inherited from Contact

Enable/disable this contact. This can be used inside the pre-solve contact listener. The contact is only disabled for the current time step (or sub-step in continuous collisions).

bool get enabled => (flags & ENABLED_FLAG) == ENABLED_FLAG;
void set enabled(bool flag) {
 if (flag) {
   flags |= ENABLED_FLAG;
 } else {
   flags &= ~ENABLED_FLAG;
 }
}

Fixture fixtureA #

inherited from Contact
Fixture fixtureA;

Fixture fixtureB #

inherited from Contact
Fixture fixtureB;

int flags #

inherited from Contact

The flags for this Contact.

int flags;

Manifold manifold #

inherited from Contact
Manifold manifold;

Contact next #

inherited from Contact
Contact next;

DefaultWorldPool pool #

inherited from Contact
DefaultWorldPool pool;

Contact prev #

inherited from Contact

World pool and list pointers.

Contact prev;

num toiCount #

inherited from Contact
num toiCount;

final bool touching #

inherited from Contact

Is this contact touching

bool get touching => (flags & TOUCHING_FLAG) == TOUCHING_FLAG;

Methods

void evaluate(Manifold argManifold, Transform xfA, Transform xfB) #

Abstract method.

docs inherited from Contact
void evaluate(Manifold argManifold, Transform xfA, Transform xfB) {
 pool.collision.collidePolygonAndCircle(argManifold, fixtureA.shape,
     xfA, fixtureB.shape, xfB);
}

void flagForFiltering() #

inherited from Contact

Flag this contact for filtering. Filtering will occur the next time step.

void flagForFiltering() {
 flags |= FILTER_FLAG;
}

void getWorldManifold(WorldManifold worldManifold) #

inherited from Contact

Intializes the given world manifold.

void getWorldManifold(WorldManifold worldManifold) {
 final Body bodyA = fixtureA.body;
 final Body bodyB = fixtureB.body;
 final Shape shapeA = fixtureA.shape;
 final Shape shapeB = fixtureB.shape;

 worldManifold.initialize(manifold, bodyA.originTransform,
     shapeA.radius, bodyB.originTransform, shapeB.radius);
}

void init(Fixture fA, Fixture fB) #

Initialization for pooling.

docs inherited from Contact
void init(Fixture fA, Fixture fB) {
 Expect.equals(ShapeType.POLYGON, fA.type);
 Expect.equals(ShapeType.CIRCLE, fB.type);
 super.init(fA, fB);
}

void update(ContactListener listener) #

inherited from Contact
void update(ContactListener listener) {
 _oldManifold.setFrom(manifold);

 // Re-enable this contact.
 flags |= ENABLED_FLAG;

 bool touching = false;
 bool wasTouching = (flags & TOUCHING_FLAG) == TOUCHING_FLAG;

 bool sensorA = fixtureA.isSensor;
 bool sensorB = fixtureB.isSensor;
 bool sensor = sensorA || sensorB;

 Body bodyA = fixtureA.body;
 Body bodyB = fixtureB.body;
 Transform xfA = bodyA.originTransform;
 Transform xfB = bodyB.originTransform;

 if (sensor) {
   Shape shapeA = fixtureA.shape;
   Shape shapeB = fixtureB.shape;
   touching = pool.collision.testOverlap(shapeA, shapeB, xfA, xfB);

   // Sensors don't generate manifolds.
   manifold.pointCount = 0;
 } else {
   evaluate(manifold, xfA, xfB);
   touching = manifold.pointCount > 0;

   // Match old contact ids to new contact ids and copy the
   // stored impulses to warm start the solver.
   for (int i = 0; i < manifold.pointCount; ++i) {
     ManifoldPoint mp2 = manifold.points[i];
     mp2.normalImpulse = 0.0;
     mp2.tangentImpulse = 0.0;
     ContactID id2 = mp2.id;

     for (int j = 0; j < _oldManifold.pointCount; ++j) {
       ManifoldPoint mp1 = _oldManifold.points[j];

       if (mp1.id.isEqual(id2)) {
         mp2.normalImpulse = mp1.normalImpulse;
         mp2.tangentImpulse = mp1.tangentImpulse;
         break;
       }
     }
   }

   if (touching != wasTouching) {
     bodyA.awake = true;
     bodyB.awake = true;
   }
 }

 if (touching) {
   flags |= TOUCHING_FLAG;
 } else {
   flags &= ~TOUCHING_FLAG;
 }

 if (listener == null) {
   return;
 }

 if (wasTouching == false && touching == true) {
   listener.beginContact(this);
 }

 if (wasTouching == true && touching == false) {
   listener.endContact(this);
 }

 if (sensor == false && touching) {
   listener.preSolve(this, _oldManifold);
 }
}