/// <summary> /// Similar to create, with an additional Starting vector (to indicate the lowest position used from Shape). /// </summary> public static Octree <T> Create(IInfiniteShape <T> Shape, Vector <int> Start, int Depth) { if (Depth == 0) { return(Singleton(Shape.Lookup(Start))); } else { int hsize = _Pow2(Depth - 1); Octree <T>[] childrens = new Octree <T> [8]; int i = 0; for (int x = 0; x < 2; x++) { for (int y = 0; y < 2; y++) { for (int z = 0; z < 2; z++) { childrens[i] = Create(Shape, Vector.Add(Start, new Vector <int>(x * hsize, y * hsize, z * hsize)), Depth - 1); i++; } } } return(HashedRecursiveSpatialStructure <T, Octree <T> > .Get(Depth, childrens)); } }