Exemplo n.º 1
0
        public override List <T> queryArea(AABB2D areaToQuery, List <T> entitiesFound)
        {
            //Check for instersection with entity if one is held in this node
            if (HasEntity)
            {
                IHasAABB2D rectEntity = (IHasAABB2D)_entity;
                if (areaToQuery.intersects(rectEntity.BoundingBox))
                {
                    entitiesFound.Add(_entity);
                }
            }

            //Check child nodes for intersection, and query them if so.
            if (HasChildren)
            {
                for (int i = 0; i < QUADS; i++)
                {
                    if (areaToQuery.intersects(_children[i].BoundingBox))
                    {
                        entitiesFound = _children[i].queryArea(areaToQuery, entitiesFound);
                    }
                }
            }
            return(entitiesFound);
        }