示例#1
0
        internal OctTreeNode(OctTree <T> a_octTree)
        {
            m_octTree = a_octTree;

            m_depth = 0;

            m_parent   = null;
            m_children = null;
        }
示例#2
0
        public void Spit()
        {
            if (m_depth < m_octTree.MaxDepth)
            {
                m_children = new OctTreeNode <T> [8];

                for (int i = 0; i < 8; ++i)
                {
                    OctTreeNode <T> child = new OctTreeNode <T>();
                    child.m_parent = this;
                    child.m_depth  = m_depth + 1;
                    m_children[i]  = child;
                }
            }
        }
示例#3
0
        public OctTreeNode <T> GetChild(int a_x, int a_y, int a_z)
        {
            int size = m_maxDepth * m_maxDepth;

            OctTreeNode <T> node = m_rootNode;

            int x = a_x;
            int y = a_y;
            int z = a_z;

            while (!node.IsLeaf)
            {
                int depth    = node.Depth;
                int depthSqr = depth * depth;

                int gridSize     = size / depthSqr;
                int halfGridSize = gridSize / 2;

                int index = 0;

                if (x >= halfGridSize)
                {
                    index |= 1 << 0;
                    x     -= halfGridSize;
                }
                if (y >= halfGridSize)
                {
                    index |= 1 << 1;
                    y     -= halfGridSize;
                }
                if (z >= halfGridSize)
                {
                    index |= 1 << 2;
                    z     -= halfGridSize;
                }

                node = node.Children[index];
            }

            return(node);
        }
示例#4
0
 public OctTree(int a_maxDepth)
 {
     m_rootNode = new OctTreeNode <T>(this);
 }