Esempio n. 1
0
        /// <summary>
        /// Finds a contaning quad node.
        /// </summary>
        public QuadNode GetNodeContaining(ref CollideElement bounds)
        {
            if (this.IsLeafNode == false)
            {
                //  checks with upper left node.
                if (UpperLeftNode != null)
                {
                    if (UpperLeftNode.Contains(ref bounds))
                    {
                        return(UpperLeftNode.GetNodeContaining(ref bounds));
                    }
                }

                //  checks with upper right node.
                if (UpperRightNode != null)
                {
                    if (UpperRightNode.Contains(ref bounds))
                    {
                        return(UpperRightNode.GetNodeContaining(ref bounds));
                    }
                }

                //  checks with lower left node.
                if (LowerLeftNode != null)
                {
                    if (LowerLeftNode.Contains(ref bounds))
                    {
                        return(LowerLeftNode.GetNodeContaining(ref bounds));
                    }
                }

                //  checks with lower right node.
                if (LowerLeftNode != null)
                {
                    if (LowerLeftNode.Contains(ref bounds))
                    {
                        return(LowerLeftNode.GetNodeContaining(ref bounds));
                    }
                }
            }

            //  checks with this node.
            if (this.Contains(ref bounds))
            {
                return(this);
            }

            return(null);
        }