Dart Documentationbox2d_consoleCircleContact

CircleContact class

class CircleContact extends Contact {
  CircleContact(DefaultWorldPool argPool) : super(argPool) { }

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

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

Extends

Contact > CircleContact

Constructors

new CircleContact(DefaultWorldPool argPool) #

CircleContact(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 () {
  return (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;

final Type runtimeType #

inherited from Object

A representation of the runtime type of the object.

external Type get runtimeType;

num toiCount #

inherited from Contact
num toiCount;

final bool touching #

inherited from Contact

Is this contact touching

bool get touching() {
  return (flags & TOUCHING_FLAG) == TOUCHING_FLAG;
}

Operators

bool operator ==(other) #

inherited from Object

The equality operator.

The default behavior for all Objects is to return true if and only if this and other are the same object.

If a subclass overrides the equality operator it should override the hashCode method as well to maintain consistency.

bool operator ==(other) => identical(this, other);

Methods

new CircleContact(DefaultWorldPool argPool) #

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

new Contact(DefaultWorldPool pool) #

inherited from Contact
Contact(DefaultWorldPool pool) :
  manifold = new Manifold(),
  fixtureA = null,
  fixtureB = null,
  edge1 = new ContactEdge(),
  edge2 = new ContactEdge(),
  pool = pool,
  _oldManifold = new Manifold() { }

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

Abstract method.

docs inherited from Contact
void evaluate(Manifold argManifold, Transform xfA, Transform xfB) {
  pool.collision.collideCircles(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);
}

int hashCode() #

inherited from Object

Get a hash code for this object.

All objects have hash codes. Hash codes are guaranteed to be the same for objects that are equal when compared using the equality operator ==. Other than that there are no guarantees about the hash codes. They will not be consistent between runs and there are no distribution guarantees.

If a subclass overrides hashCode it should override the equality operator as well to maintain consistency.

external int hashCode();

void init(Fixture fA, Fixture fB) #

Initialization for pooling.

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

noSuchMethod(String name, List args) #

inherited from Object

noSuchMethod is invoked when users invoke a non-existant method on an object. The name of the method and the arguments of the invocation are passed to noSuchMethod. If noSuchMethod returns a value, that value becomes the result of the original invocation.

The default behavior of noSuchMethod is to throw a noSuchMethodError.

external Dynamic noSuchMethod(String name, List args);

const Object() #

inherited from Object

Creates a new Object instance.

Object instances have no meaningful state, and are only useful through their identity. An Object instance is equal to itself only.

const Object();

String toString() #

inherited from Object

Returns a string representation of this object.

external String toString();

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);
  }
}