Exemple #1
0
 /// <summary>
 /// Recursive method which moves down the hierarchy performing overlap tests
 /// against 'box'. At the end of the recursive chain, all terminal nodes which
 /// are overlapped by 'box' will be stored in 'overlappedNodes'.
 /// </summary>
 private void OverlapBoxRecurse(OBB box, SphereTreeNode <T> node, List <SphereTreeNode <T> > overlappedNodes)
 {
     // If the parent node is not overlapped, its children can not possibly
     // be overlapped so thre is no need to go any further.
     if (!box.IntersectsSphere(node.Sphere))
     {
         return;
     }
     else
     {
         // If this is a terminal node, add it to the output list and return
         if (node.IsFlagBitSet(BVHNodeFlags.Terminal))
         {
             overlappedNodes.Add(node);
             return;
         }
         else
         {
             // Recurse for each child node
             List <SphereTreeNode <T> > childNodes = node.Children;
             foreach (SphereTreeNode <T> childNode in childNodes)
             {
                 OverlapBoxRecurse(box, childNode, overlappedNodes);
             }
         }
     }
 }