Пример #1
0
        public override List <int> Query(Rectangle bounds)
        {
            List <int> result = new List <int>();

            if (Boundary.EntirelyWithin(bounds))
            {
                for (int i = 0; i < objects.Length; i++)
                {
                    if (objects[i] == null)
                    {
                        continue;
                    }

                    result.Add(objects[i].Identifier);
                }
            }
            else
            {
                for (int i = 0; i < objects.Length; i++)
                {
                    if (objects[i] == null)
                    {
                        continue;
                    }

                    if (bounds.Intersects(objects[i].Bounds))
                    {
                        result.Add(objects[i].Identifier);
                    }
                }
            }

            if (!divided)
            {
                return(result);
            }

            result.AddRange(topLeft.Query(bounds));
            result.AddRange(topRight.Query(bounds));
            result.AddRange(bottomRight.Query(bounds));
            result.AddRange(bottomLeft.Query(bounds));

            return(result);
        }