/// <summary> /// The pool. /// </summary> /// <param name="cell"> /// The cell. /// </param> public static void Pool([NotNull] Spatial3DCell <T> cell) { if (CellPool.Count >= MaxCellPoolItems) { return; } if (cell.Children != null) { Pool(cell.Children); cell.Children = null; } cell.Items.Clear(); cell.TotalItemAmount = 0; CellPool.Push(cell); }
public static Spatial3DCell <T> GetCell(Vector3 start, Vector3 size, bool addChildren = false) { Spatial3DCell <T> cell; if (CellPool.Count > 0) { cell = CellPool.Pop(); cell.Start = start; cell.Size = size; } else { cell = new Spatial3DCell <T>(start, size); } if (addChildren) { cell.Children = GetChildArray(); } return(cell); }