Exemplo n.º 1
0
        public void Split(Split split)
        {
            List<SplitTreeNode> newGeneration = new List<SplitTreeNode>();
            foreach(SplitTreeNode child in _latestGeneration)
            {
                BlockBounds childBounds = child.bounds;
                BlockBounds splitL, splitR;
                this.Split(split.Axis, split.Value, childBounds, out splitL, out splitR);

                if ((splitL != null) && (splitR != null))
                {
                    SplitTreeNode nodeL = new SplitTreeNode(child, splitL);
                    SplitTreeNode nodeR = new SplitTreeNode(child, splitR);

                    newGeneration.Add(nodeL);
                    newGeneration.Add(nodeR);

                    child.bounds = null;
                    child.children = new SplitTreeNode[] { nodeL, nodeR };

                }
                else
                {
                    newGeneration.Add(child);
                }
            }

            _latestGeneration = newGeneration.ToArray();
        }
Exemplo n.º 2
0
 public SplitTree(BlockBounds bounds)
 {
     _root = new SplitTreeNode(null, null);
     _root.children = new[] { new SplitTreeNode(_root, bounds) };
     _latestGeneration = _root.children;
 }
Exemplo n.º 3
0
 public SplitTreeNode(SplitTreeNode parent, BlockBounds bounds)
 {
     this.children = new SplitTreeNode[0];
     this.parent = parent;
     this.bounds = bounds;
 }