Example #1
0
 public PartitionNode <T> FindContainingField(SpatialObj <T> rect, PartitionNode <T> starting_node)
 {
     if (starting_node.IsPointInNode(rect.boundingBox.Center))
     {
         bool contained_in_node = starting_node.IsObjectInNode(rect);
         if (contained_in_node && !starting_node.CanSink(rect))
         {
             return(starting_node);
         }
         foreach (PartitionNode <T> child in starting_node.GetChildren())
         {
             var potential_node = FindContainingField(rect, child);
             if (potential_node != null)
             {
                 return(potential_node);
             }
         }
         if (contained_in_node)
         {
             return(starting_node);
         }
     }
     return(null);
 }