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); }
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; } }
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; } }
private void DisposeAndMoveHolders(ref KdTreeNode <T> node, KdTreeNode <T> newLeaf, KdTree <T> tree) { node.DisposeChildrenAndMoveHolders(newLeaf, tree); tree.DisposeNode(node); node = null; }
private void ConvertToLeaf(KdTree <T> tree) { leaf.holder = null; DisposeChildrenAndMoveHolders(this, tree); type = NodeType.Leaf; }
private void PostProcessNewChildNode(KdTree <T> tree, KdTreeNode <T> node) { node.RefreshBounds(); tree.MarkRebalanceIfNeeded(node); }