Example #1
0
        /// <summary>
        /// display build information to debug output window.
        /// </summary>
        /// <returns>total vertex count</returns>
        public int Dump()
        {
            int vertexCount = this.VertextCount;

            System.Diagnostics.Debug.WriteLine(
                this.Name + "[" + this.Depth + "] vertex = " +
                this.VertextCount.ToString() + ")");

            if (UpperLeftNode != null)
            {
                vertexCount += UpperLeftNode.Dump();
            }

            if (UpperRightNode != null)
            {
                vertexCount += UpperRightNode.Dump();
            }

            if (LowerLeftNode != null)
            {
                vertexCount += LowerLeftNode.Dump();
            }

            if (LowerRightNode != null)
            {
                vertexCount += LowerRightNode.Dump();
            }

            return(vertexCount);
        }
Example #2
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);
        }