Ejemplo n.º 1
0
        public IEnumerable <VOBoundsDepthNode> GetAllNonNullBoundsNodes()
        {
            var nodes = new Stack <VOBoundsDepthNode>();

            nodes.Push(new VOBoundsDepthNode(root, bounds));
            while (nodes.Count > 0)
            {
                var node = nodes.Pop();
                yield return(node);

                if (node.node.isLeaf)
                {
                    continue;
                }
                for (int i = 0; i < 8; ++i)
                {
                    var n = node.node[i];
                    if (n == null)
                    {
                        continue;
                    }
                    nodes.Push(
                        new VOBoundsDepthNode(n, OctPositionVector.FromIndex(i).octant(node.bounds))
                        );
                }
            }
        }
Ejemplo n.º 2
0
        public FlatVOTree <T> GetFlatTree()
        {
            var result = new Queue <FlatVONode <T> > [_maxDepth];

            for (int i = 0; i < _maxDepth; ++i)
            {
                result[i] = new Queue <FlatVONode <T> >();
            }

            var nodes = new Stack <VOBoundsDepthNode>();

            nodes.Push(new VOBoundsDepthNode(root, bounds, 0, -1));
            while (nodes.Count > 0)
            {
                var node       = nodes.Pop();
                int childCount = 0;
                for (int i = 0; i < 8; ++i)
                {
                    if (node.node[i] != null)
                    {
                        childCount++;
                        nodes.Push(new VOBoundsDepthNode(node.node[i], OctPositionVector.FromIndex(i).octant(node.bounds), node.depth + 1, i));
                    }
                }
            }

            return(default(FlatVOTree <T>));
        }