예제 #1
0
 /// <summary>
 /// Gets a list of items containing a specified point
 /// </summary>
 /// <param name="Point">The point</param>
 /// <param name="ItemsFound">The list to add found items to (list will not be cleared first)</param>
 public void GetItems(Vector2 Point, ref List <QuadTreePositionItem <T> > ItemsList)
 {
     if (ItemsList != null)
     {
         headNode.GetItems(Point, ref ItemsList);
     }
 }
예제 #2
0
        /// <summary>
        /// Gets a list of items containing a specified point
        /// </summary>
        /// <param name="Point">The point</param>
        /// <param name="ItemsFound">The list to add found items to (list will not be cleared first)</param>
        /// <remarks>ItemsFound is assumed to be initialized, and will not be cleared</remarks>
        public void GetItems(Vector2 Point, ref List <QuadTreePositionItem <T> > ItemsFound)
        {
            // test the point against this node
            if (Rect.Contains(Point))
            {
                // test the point in each item
                foreach (QuadTreePositionItem <T> Item in Items)
                {
                    if (Item.Rect.Contains(Point))
                    {
                        ItemsFound.Add(Item);
                    }
                }

                // query all subtrees
                if (IsPartitioned)
                {
                    TopLeftNode.GetItems(Point, ref ItemsFound);
                    TopRightNode.GetItems(Point, ref ItemsFound);
                    BottomLeftNode.GetItems(Point, ref ItemsFound);
                    BottomRightNode.GetItems(Point, ref ItemsFound);
                }
            }
        }