isAvailablePair method

bool isAvailablePair(
  1. Shape s1,
  2. Shape s2
)

Returns whether the pair is available or not.

Implementation

bool isAvailablePair(Shape s1,Shape s2 ) {
  RigidBody b1 = s1.parent!;
  RigidBody b2 = s2.parent!;

  if( b1 == b2 || // same parents
    (!b1.isDynamic && !b2.isDynamic) || // static or kinematic object
    (s1.belongsTo&s2.collidesWith)==0 ||
    (s2.belongsTo&s1.collidesWith)==0 // collision filtering
  ){
    return false;
  }

  JointLink? js;
  if(b1.numJoints < b2.numJoints){
    js = b1.jointLink;
  }
  else{
    js = b2.jointLink;
  }

  while(js!=null){
    Joint joint = js.joint;
    if( !joint.allowCollision && ((joint.body1==b1 && joint.body2==b2) || (joint.body1==b2 && joint.body2==b1)) ){
      return false;
    }
    js = js.next;
  }

  return true;
}