Пример #1
0
        /// <summary>
        /// DOES NOT WORK. WIP. probably because the additems() doesnt work correctly.
        /// </summary>
        /// <param name="items"></param>
        /// <param name="area"></param>
        /// <param name="skipChecks"></param>
        public void GetItemsWithinArea(ref List <T> items, ref FRect area, bool skipChecks)
        {
            if (skipChecks || AABB.Intersects(area))
            {
                // When the area if entirely within the Cell then skip collision checks on the child nodes
                if (area.FullyEncloses(AABB))
                {
                    skipChecks = true;
                }

                foreach (T item in items)
                {
                    if (skipChecks || item.AABB.Intersects(area))
                    {
                        items.Add(item);
                    }
                }

                if (!IsLeaf)
                {
                    TopLeft.GetItemsWithinArea(ref items, ref area, skipChecks);
                    TopRight.GetItemsWithinArea(ref items, ref area, skipChecks);
                    BottomLeft.GetItemsWithinArea(ref items, ref area, skipChecks);
                    BottomRight.GetItemsWithinArea(ref items, ref area, skipChecks);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Returns all items (not nodes) that intersect with the given area.
        /// </summary>
        /// <param name="area"></param>
        /// <returns></returns>
        public List <T> GetItemsWithinArea(FRect area)
        {
            List <T> items = new List <T>();

            RootNode.GetItemsWithinArea(ref items, ref area, false);
            return(items);
        }