attach method

void attach(
  1. Shape shape1,
  2. Shape shape2
)

Attach the contact to the shapes.

shape1 First shape of the attached contact shape2 Second shape of the attached contact

Implementation

void attach(Shape shape1,Shape shape2){
  this.shape1 = shape1;
  this.shape2 = shape2;
  body1 = shape1.parent;
  body2 = shape2.parent;

  manifold.body1 = body1;
  manifold.body2 = body2;
  constraint.body1 = body1;
  constraint.body2 = body2;
  constraint.attach();

  s1Link.shape = shape2;
  s1Link.body = body2;
  s2Link.shape = shape1;
  s2Link.body = body1;

  if(shape1.contactLink != null){
    (s1Link.next = shape1.contactLink)!.prev = s1Link;
  }
  else{
    s1Link.next=null;
  }
  shape1.contactLink = s1Link;
  shape1.numContacts++;

  if(shape2.contactLink !=null ){
    (s2Link.next=shape2.contactLink)!.prev = s2Link;
  }
  else{
    s2Link.next = null;
  }
  shape2.contactLink = s2Link;
  shape2.numContacts++;

  b1Link.shape = shape2;
  b1Link.body = body2;
  b2Link.shape = shape1;
  b2Link.body = body1;

  if(body1!.contactLink!=null){
    (b1Link.next = body1!.contactLink)!.prev = b1Link;
  }
  else{
    b1Link.next=null;
  }
  body1!.contactLink = b1Link;
  body1!.numContacts++;

  if(body2!.contactLink!=null){
    (b2Link.next=body2!.contactLink)!.prev = b2Link;
  }
  else{
    b2Link.next=null;
  }
  body2!.contactLink = b2Link;
  body2!.numContacts++;

  prev = null;
  next = null;

  persisting = true;
  sleeping = body1!.sleeping&&body2!.sleeping;
  manifold.numPoints=0;
}