Exemple #1
0
        public bool Set(T leaf, Vector3f pos)
        {
            if (!bounds.Contains(pos))
            {
                return(false);
            }
            var    subBounds = bounds;
            VONode node      = root;
            VONode subNode;

            for (int i = 1; i <= _maxDepth; ++i)
            {
                subNode = node.GetAt(pos, subBounds.center);
                if (subNode == null)
                {
                    if (i == _maxDepth)
                    {
                        subNode = new VOLeafNode();
                    }
                    else
                    {
                        subNode = new VOInternalNode();
                    }
                    node.SetAt(subNode, pos, subBounds.center);
                }
                subBounds = GetOctant(subBounds, pos);
                node      = subNode;
            }
            node.data = leaf;
            return(true);
        }
Exemple #2
0
 public void SetAt(VONode node, Vector3f pos, Vector3f reference)
 {
     if (children == null)
     {
         return;
     }
     children.SetAt(node, pos, reference);
 }
Exemple #3
0
        public bool Get(Vector3f pos, out T leaf)
        {
            leaf = default(T);
            if (!bounds.Contains(pos))
            {
                return(false);
            }
            var    subBounds = bounds;
            VONode subNode   = root;

            for (int i = 1; i <= _maxDepth; ++i)
            {
                subNode = subNode.GetAt(pos, subBounds.center);
                if (subNode == null)
                {
                    return(false);
                }
                subBounds = GetOctant(subBounds, pos);
            }
            leaf = subNode.data;
            return(true);
        }
Exemple #4
0
 public VOBoundsDepthNode(VONode node, Bounds bounds, int depth, int octantIndex)
 {
     this.node = node; this.bounds = bounds; this.depth = depth; this.octantIndex = octantIndex;
 }
Exemple #5
0
 public VOBoundsDepthNode(VONode node, Bounds bounds, int depth) : this(node, bounds, depth, -1)
 {
 }
Exemple #6
0
 public VOBoundsDepthNode(VONode node, Bounds bounds) : this(node, bounds, -1)
 {
 }
Exemple #7
0
 public VODepthNode(VONode node, int depth)
 {
     this.node = node; this.depth = depth;
 }
Exemple #8
0
 public VoxelOctree(int _maxDepth, Bounds bounds)
 {
     this._maxDepth = _maxDepth;
     this.bounds    = bounds;
     root           = new VOInternalNode();
 }