Exemplo n.º 1
0
 public void FindPotentialCollisionsWith(List<Contact> Potentials, BVHNode other)
 {
     if (!CollidesWith(other))
     {
         if (!this.isLeaf())
             this.FindPotentialCollisions(Potentials);
         if (!other.isLeaf())
             other.FindPotentialCollisions(Potentials);
         return;
     }
     if (this.isLeaf() && other.isLeaf())
     {
         Contact temp = new Contact(this.Body, other.Body);
         if (!temp.BothFixed())
             Potentials.Add(temp);
     }
     else if (other.isLeaf() && !this.isLeaf())
     {
         this.Children[0].FindPotentialCollisionsWith(Potentials, other);
         this.Children[1].FindPotentialCollisionsWith(Potentials, other);
         this.FindPotentialCollisions(Potentials);
     }
     else if (this.isLeaf() && !other.isLeaf())
     {
         other.Children[0].FindPotentialCollisionsWith(Potentials, this);
         other.Children[1].FindPotentialCollisionsWith(Potentials, this);
     }
     else
     {
         other.Children[0].FindPotentialCollisionsWith(Potentials, this.Children[0]);
         other.Children[0].FindPotentialCollisionsWith(Potentials, this.Children[1]);
         other.Children[1].FindPotentialCollisionsWith(Potentials, this.Children[0]);
         other.Children[1].FindPotentialCollisionsWith(Potentials, this.Children[1]);
         this.FindPotentialCollisions(Potentials);
         other.FindPotentialCollisions(Potentials);
     }
 }