/// <summary>
 /// Initializes a new instance of the <see cref="Spatial3DTree{T}" /> class.
 /// </summary>
 /// <param name="size">The initial size of the root.</param>
 /// <param name="center">The center of the root.</param>
 /// <param name="allowDuplicates">A value indicating whether duplicate elements are detected and duplicate entries are prevented when adding or moving items (Two items are duplicates if value and position are equal)</param>
 public Spatial3DTree(Vector3 size, Vector3 center, bool allowDuplicates = true)
 {
     this.allowDuplicates = allowDuplicates;
     this.initialSize     = size;
     this.center          = center;
     root = Spatial3DCell <T> .GetCell(this.center - initialSize / 2f, initialSize, false);
 }
        /// <summary>
        ///     The clear.
        /// </summary>
        public void Clear()
        {
            version++;
            Spatial3DCell <T> .Pool(root);

            root = Spatial3DCell <T> .GetCell(center - initialSize / 2, initialSize);
        }
        /// <summary>
        ///     The grow.
        /// </summary>
        private void Grow()
        {
            const int sc       = Spatial3DCell <T> .SubdivisionAmount;
            const int scCenter = sc / 2;

            var start = root.Start - scCenter * root.Size;
            var size  = root.Size * sc;

            if (root.Children == null)
            {
                root.Start = start;
                root.Size  = size;
            }
            else
            {
                var newRoot = Spatial3DCell <T> .GetCell(start, size, true);

                newRoot.TotalItemAmount = root.TotalItemAmount;
                newRoot.Children[newRoot.Children.Length / 2] = root;
                root = newRoot;
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="Spatial3DTree{T}" /> class.
 /// </summary>
 /// <param name="size">The initial size of the root.</param>
 /// <param name="center">The center of the root.</param>
 public Spatial3DTree(Vector3 size, Vector3 center)
 {
     initialSize = size;
     this.center = center;
     root        = Spatial3DCell <T> .GetCell(this.center - initialSize / 2f, initialSize, false);
 }