コード例 #1
0
 public bool Update(KdTree <T> tree)
 {
     fitRect = tree.GetBodyFitRect(body);
     if (fatRect.Contains(fitRect) && refresh > 0)
     {
         refresh--;
         // body still in fat rect, skipping
         return(false);
     }
     fatRect = tree.GetBodyFatRect(body);
     refresh = tree.newRefresh;
     return(true);
 }
コード例 #2
0
        public void Rebalance(KdTree <T> tree)
        {
            switch (type)
            {
            case NodeType.Inner:
            {
                if (count <= 1)
                {
                    ConvertToLeaf(tree);
                }
                else
                {
                    ConvertToLeaf(tree);
                    ConvertToInnerMaybe(tree);     // TODO: proper progressive rebalancing
                }
            } break;

            case NodeType.Leaf:
            {
                ConvertToInnerMaybe(tree);
            } break;
            }
        }
コード例 #3
0
        private void DisposeChildrenAndMoveHolders(KdTreeNode <T> newLeaf, KdTree <T> tree)
        {
            switch (type)
            {
            case NodeType.Inner:
            {
                DisposeAndMoveHolders(ref inner.nodeLess, newLeaf, tree);
                DisposeAndMoveHolders(ref inner.nodeBoth, newLeaf, tree);
                DisposeAndMoveHolders(ref inner.nodeMore, newLeaf, tree);
            } break;

            case NodeType.Leaf:
            {
                var holder = leaf.holder;
                leaf.holder = null;
                while (holder != null)
                {
                    var next = holder.sibling.next;
                    holder.AddToHolderList(newLeaf);
                    holder = next;
                }
            } break;
            }
        }
コード例 #4
0
 private void DisposeAndMoveHolders(ref KdTreeNode <T> node, KdTreeNode <T> newLeaf, KdTree <T> tree)
 {
     node.DisposeChildrenAndMoveHolders(newLeaf, tree);
     tree.DisposeNode(node);
     node = null;
 }
コード例 #5
0
 private void ConvertToLeaf(KdTree <T> tree)
 {
     leaf.holder = null;
     DisposeChildrenAndMoveHolders(this, tree);
     type = NodeType.Leaf;
 }
コード例 #6
0
 private void PostProcessNewChildNode(KdTree <T> tree, KdTreeNode <T> node)
 {
     node.RefreshBounds();
     tree.MarkRebalanceIfNeeded(node);
 }