コード例 #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);
        }
コード例 #2
0
 public void SetAt(VONode node, Vector3f pos, Vector3f reference)
 {
     if (children == null)
     {
         return;
     }
     children.SetAt(node, pos, reference);
 }
コード例 #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);
        }
コード例 #4
0
 public VOBoundsDepthNode(VONode node, Bounds bounds, int depth, int octantIndex)
 {
     this.node = node; this.bounds = bounds; this.depth = depth; this.octantIndex = octantIndex;
 }
コード例 #5
0
 public VOBoundsDepthNode(VONode node, Bounds bounds, int depth) : this(node, bounds, depth, -1)
 {
 }
コード例 #6
0
 public VOBoundsDepthNode(VONode node, Bounds bounds) : this(node, bounds, -1)
 {
 }
コード例 #7
0
 public VODepthNode(VONode node, int depth)
 {
     this.node = node; this.depth = depth;
 }
コード例 #8
0
 public VoxelOctree(int _maxDepth, Bounds bounds)
 {
     this._maxDepth = _maxDepth;
     this.bounds    = bounds;
     root           = new VOInternalNode();
 }