private void CreateChildren() { if (IsLeaf) { // create each of the child octants for (int i = 0; i < 8; i++) { children[i] = new Octant <T>(this, GetChildBounds(Bounds, (Boolean3)i)); } IsLeaf = false; // relocate items which can fit in children octents foreach (var item in Items.FindAll(item => item.Radius <= Extent / 2)) { Items.Remove(item); Add(item); } } }
/// <summary> /// /// </summary> public Octant(Octant <T> parent, Bounds3 bounds) { Bounds = bounds; Influence = Bounds3.FromCenter(bounds.Center, bounds.Size * 3); }
public Octree(Vector3 center, float side) { Bounds = Bounds3.FromCenter(center, new Vector3(side)); Root = new Octant <T>(null, Bounds); }