/// <summary>
        /// Split the Quadtree
        /// </summary>
        protected void Split()
        {
            int subWidth  = _quadBounds.Width / 2;
            int subHeight = _quadBounds.Height / 2;

            /* -----------------------
             * | _node[1] | _node[0] |
             * |----------------------
             * | _node[2] | _node[3] |
             * -----------------------
             */

            _nodes[0] = new YnQuadTree(_level + 1, new Rectangle(_quadBounds.X + subWidth, _quadBounds.Y, subWidth, subHeight));
            _nodes[1] = new YnQuadTree(_level + 1, new Rectangle(_quadBounds.X, _quadBounds.Y, subWidth, subHeight));
            _nodes[2] = new YnQuadTree(_level + 1, new Rectangle(_quadBounds.X, _quadBounds.Y + subHeight, subWidth, subHeight));
            _nodes[3] = new YnQuadTree(_level + 1, new Rectangle(_quadBounds.X + subWidth, _quadBounds.Y + subHeight, subWidth, subHeight));
        }
Exemple #2
0
        /// <summary>
        /// Split the Quadtree
        /// </summary>
        protected void Split()
        {
            int subWidth = _quadBounds.Width / 2;
            int subHeight = _quadBounds.Height / 2;

            /* ----------------------- 
             * | _node[1] | _node[0] |
             * |----------------------
             * | _node[2] | _node[3] |
             * -----------------------
             */

            _nodes[0] = new YnQuadTree(_level + 1, new Rectangle(_quadBounds.X + subWidth, _quadBounds.Y, subWidth, subHeight));
            _nodes[1] = new YnQuadTree(_level + 1, new Rectangle(_quadBounds.X, _quadBounds.Y, subWidth, subHeight));
            _nodes[2] = new YnQuadTree(_level + 1, new Rectangle(_quadBounds.X, _quadBounds.Y + subHeight, subWidth, subHeight));
            _nodes[3] = new YnQuadTree(_level + 1, new Rectangle(_quadBounds.X + subWidth, _quadBounds.Y + subHeight, subWidth, subHeight));
        }