public QuadTreeNode Get(WorldPosition worldPosition, double halfDim, int treeHeight, QuadTreeNode parent) { var tree = quadTrees.Count > 0 ? quadTrees.Pop() : new QuadTreeNode(this.quadTree, this, nodeCapacity, maxDepth); tree.SetUp(worldPosition, halfDim, treeHeight, parent); return(tree); }
public void Return(QuadTreeNode tree) => quadTrees.Push(tree);
public QuadTree(WorldPosition position, Size size, int poolSize, int nodeCapacity, int maxDepth) { pool = new QuadTreePool(this, poolSize, nodeCapacity, maxDepth); RootNode = pool.Get(position, size.Width * 0.5, 0, null); }