46   CoalScalar sqrDistLowerBound1 = 0, sqrDistLowerBound2 = 0;
 
   47   bool l1 = node->isFirstNodeLeaf(b1);
 
   48   bool l2 = node->isSecondNodeLeaf(b2);
 
   53     node->leafCollides(b1, b2, sqrDistLowerBound);
 
   57   if (node->BVDisjoints(b1, b2, sqrDistLowerBound)) {
 
   61   if (node->firstOverSecond(b1, b2)) {
 
   62     unsigned int c1 = (
unsigned int)node->getFirstLeftChild(b1);
 
   63     unsigned int c2 = (
unsigned int)node->getFirstRightChild(b1);
 
   68     if (node->canStop() && !front_list) 
return;
 
   71     sqrDistLowerBound = std::min(sqrDistLowerBound1, sqrDistLowerBound2);
 
   73     unsigned int c1 = (
unsigned int)node->getSecondLeftChild(b2);
 
   74     unsigned int c2 = (
unsigned int)node->getSecondRightChild(b2);
 
   79     if (node->canStop() && !front_list) 
return;
 
   82     sqrDistLowerBound = std::min(sqrDistLowerBound1, sqrDistLowerBound2);
 
   89   typedef std::pair<unsigned int, unsigned int> BVPair_t;
 
   91   typedef std::vector<BVPair_t> Stack_t;
 
   95   sqrDistLowerBound = std::numeric_limits<CoalScalar>::infinity();
 
   96   CoalScalar sdlb = std::numeric_limits<CoalScalar>::infinity();
 
   98   pairs.push_back(BVPair_t(0, 0));
 
  100   while (!pairs.empty()) {
 
  101     unsigned int a = pairs.back().first, 
b = pairs.back().second;
 
  104     bool la = node->isFirstNodeLeaf(
a);
 
  105     bool lb = node->isSecondNodeLeaf(
b);
 
  116       node->leafCollides(
a, 
b, sdlb);
 
  117       if (sdlb < sqrDistLowerBound) sqrDistLowerBound = sdlb;
 
  118       if (node->canStop() && !front_list) 
return;
 
  128     if (node->BVDisjoints(
a, 
b, sdlb)) {
 
  129       if (sdlb < sqrDistLowerBound) sqrDistLowerBound = sdlb;
 
  134     if (node->firstOverSecond(
a, 
b)) {
 
  135       unsigned int c1 = (
unsigned int)node->getFirstLeftChild(
a);
 
  136       unsigned int c2 = (
unsigned int)node->getFirstRightChild(
a);
 
  137       pairs.push_back(BVPair_t(
c2, 
b));
 
  138       pairs.push_back(BVPair_t(c1, 
b));
 
  140       unsigned int c1 = (
unsigned int)node->getSecondLeftChild(
b);
 
  141       unsigned int c2 = (
unsigned int)node->getSecondRightChild(
b);
 
  142       pairs.push_back(BVPair_t(
a, 
c2));
 
  143       pairs.push_back(BVPair_t(
a, c1));
 
  154   bool l1 = node->isFirstNodeLeaf(b1);
 
  155   bool l2 = node->isSecondNodeLeaf(b2);
 
  160     node->leafComputeDistance(b1, b2);
 
  164   unsigned int a1, a2, c1, 
c2;
 
  166   if (node->firstOverSecond(b1, b2)) {
 
  167     a1 = (
unsigned int)node->getFirstLeftChild(b1);
 
  169     c1 = (
unsigned int)node->getFirstRightChild(b1);
 
  173     a2 = (
unsigned int)node->getSecondLeftChild(b2);
 
  175     c2 = (
unsigned int)node->getSecondRightChild(b2);
 
  182     if (!node->canStop(d2))
 
  187     if (!node->canStop(
d1))
 
  192     if (!node->canStop(
d1))
 
  197     if (!node->canStop(d2))
 
  215                                    const {
return lhs.
d > rhs.
d;
 
  223   bool empty()
 const { 
return pq.empty(); }
 
  225   size_t size()
 const { 
return pq.size(); }
 
  227   const BVT& 
top()
 const { 
return pq.top(); }
 
  233   bool full()
 const { 
return (pq.size() + 1 >= qsize); }
 
  243                           unsigned int qsize) {
 
  252     bool l1 = node->isFirstNodeLeaf(min_test.
b1);
 
  253     bool l2 = node->isSecondNodeLeaf(min_test.
b2);
 
  258       node->leafComputeDistance(min_test.
b1, min_test.
b2);
 
  259     } 
else if (bvtq.
full()) {
 
  267       if (node->firstOverSecond(min_test.
b1, min_test.
b2)) {
 
  268         unsigned int c1 = (
unsigned int)node->getFirstLeftChild(min_test.
b1);
 
  269         unsigned int c2 = (
unsigned int)node->getFirstRightChild(min_test.
b1);
 
  271         bvt1.
b2 = min_test.
b2;
 
  272         bvt1.
d = node->BVDistanceLowerBound(bvt1.
b1, bvt1.
b2);
 
  275         bvt2.
b2 = min_test.
b2;
 
  276         bvt2.
d = node->BVDistanceLowerBound(bvt2.
b1, bvt2.
b2);
 
  278         unsigned int c1 = (
unsigned int)node->getSecondLeftChild(min_test.
b2);
 
  279         unsigned int c2 = (
unsigned int)node->getSecondRightChild(min_test.
b2);
 
  280         bvt1.
b1 = min_test.
b1;
 
  282         bvt1.
d = node->BVDistanceLowerBound(bvt1.
b1, bvt1.
b2);
 
  284         bvt2.
b1 = min_test.
b1;
 
  286         bvt2.
d = node->BVDistanceLowerBound(bvt2.
b1, bvt2.
b2);
 
  296       min_test = bvtq.
top();
 
  299       if (node->canStop(min_test.
d)) {
 
  311   CoalScalar sqrDistLowerBound = -1, sqrDistLowerBound1 = 0,
 
  312              sqrDistLowerBound2 = 0;
 
  313   BVHFrontList::iterator front_iter;
 
  315   for (front_iter = front_list->begin(); front_iter != front_list->end();
 
  317     unsigned int b1 = front_iter->left;
 
  318     unsigned int b2 = front_iter->right;
 
  319     bool l1 = node->isFirstNodeLeaf(b1);
 
  320     bool l2 = node->isSecondNodeLeaf(b2);
 
  323       front_iter->valid = 
false;  
 
  327       if (!node->BVDisjoints(b1, b2, sqrDistLowerBound)) {
 
  328         front_iter->valid = 
false;
 
  329         if (node->firstOverSecond(b1, b2)) {
 
  330           unsigned int c1 = (
unsigned int)node->getFirstLeftChild(b1);
 
  331           unsigned int c2 = (
unsigned int)node->getFirstRightChild(b1);
 
  335           sqrDistLowerBound = std::min(sqrDistLowerBound1, sqrDistLowerBound2);
 
  337           unsigned int c1 = (
unsigned int)node->getSecondLeftChild(b2);
 
  338           unsigned int c2 = (
unsigned int)node->getSecondRightChild(b2);
 
  342           sqrDistLowerBound = std::min(sqrDistLowerBound1, sqrDistLowerBound2);
 
  350   for (front_iter = front_list->begin(); front_iter != front_list->end();) {
 
  351     if (!front_iter->valid)
 
  352       front_iter = front_list->erase(front_iter);
 
  357   for (front_iter = append.begin(); front_iter != append.end(); ++front_iter) {
 
  358     front_list->push_back(*front_iter);