AStarCollisionMap.QuadTree.Quad.Split C# (CSharp) Method

Split() public method

public Split ( ) : Quad[]
return Quad[]
        public Quad[] Split()
        {
            Quad[] quads = new Quad[4];

            int leftWidth = this.rectangle.Width / 2;
            int rightWidth = this.rectangle.Width - leftWidth;
            int topHeight = this.rectangle.Height / 2;
            int bottomHeight = this.rectangle.Height - topHeight;
            // [*][ ]
            // [ ][ ]
            quads[0] = new Quad(this.tree, this,
                new Rectangle(this.rectangle.Left, this.rectangle.Top, leftWidth, topHeight));
            // [ ][*]
            // [ ][ ]
            quads[1] = new Quad(this.tree, this,
                new Rectangle(this.rectangle.Left + leftWidth, this.rectangle.Top, rightWidth, topHeight));
            // [ ][ ]
            // [*][ ]
            quads[2] = new Quad(this.tree, this,
                new Rectangle(this.rectangle.Left, this.rectangle.Top + topHeight, leftWidth, bottomHeight));
            // [ ][ ]
            // [ ][*]
            quads[3] = new Quad(this.tree, this,
                new Rectangle(this.rectangle.Left + rightWidth, this.rectangle.Top + topHeight, rightWidth, bottomHeight));

            this.children = quads;
            return quads;
        }