예제 #1
0
        /// <summary>
        /// Resizes the Quadtree field
        /// </summary>
        /// <param name="newWorld">The new field</param>
        /// <remarks>This is an expensive operation, so try to initialize the world to a big enough size</remarks>
        public void Resize(FRect newWorld)
        {
            // Get all of the items in the tree
            List <QuadTreePositionItem <T> > Components = new List <QuadTreePositionItem <T> >();

            GetAllItems(ref Components);

            // Destroy the head node
            headNode.Destroy();
            headNode = null;

            // Create a new head
            headNode = new QuadTreeNode <T>(newWorld, maxItems, Resize);

            // Reinsert the items
            foreach (QuadTreePositionItem <T> m in Components)
            {
                headNode.Insert(m);
            }
        }
예제 #2
0
        /// <summary>
        /// Destroys this node
        /// </summary>
        public void Destroy()
        {
            // Destroy all child nodes
            if (IsPartitioned)
            {
                TopLeftNode.Destroy();
                TopRightNode.Destroy();
                BottomLeftNode.Destroy();
                BottomRightNode.Destroy();

                TopLeftNode     = null;
                TopRightNode    = null;
                BottomLeftNode  = null;
                BottomRightNode = null;
            }

            // Remove all items
            while (Items.Count > 0)
            {
                RemoveItem(0);
            }
        }