Beispiel #1
0
        /// <summary>
        /// Checks to see if the actual point is in the quad tree as opposed to being bounded by it
        /// </summary>
        /// <param name="point"></param>
        /// <returns></returns>
        public bool Contains(Point2Int point)
        {
            if (!BoundingBox.ContainsPoint(point))
            {
                return(false);
            }

            if (Points != null)
            {
                return(Points.Contains(point));
            }

            var center = BoundingBox.CenterPoint();

            if (point.X < center.X)
            {
                if (point.Y < center.Y)
                {
                    // bottom left
                    return(SouthWest.Contains(point));
                }

                //top left
                return(NorthWest.Contains(point));
            }

            if (point.Y < center.Y)
            {
                // bottom right
                return(SouthEast.Contains(point));
            }
            //top right
            return(NorthEast.Contains(point));
        }
Beispiel #2
0
        private void AddPointToChildren(Point2Int point)
        {
            var center = BoundingBox.CenterPoint();

            if (point.X < center.X)
            {
                if (point.Y < center.Y)
                {
                    SouthWest.Add(point);
                    return;
                }
                NorthWest.Add(point);
                return;
            }

            if (point.Y < center.Y)
            {
                SouthEast.Add(point);
                return;
            }
            NorthEast.Add(point);
        }