/// <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)); } }
/// <summary> /// Creates a solid octree (all depth-0 octree's have the same value). /// </summary> public static Octree <T> Solid(T Value, int Depth) { if (Depth == 0) { return(Singleton(Value)); } else { Octree <T> prev = Solid(Value, Depth - 1); Octree <T>[] childrens = new Octree <T> [8]; for (int t = 0; t < 8; t++) { childrens[t] = prev; } return(HashedRecursiveSpatialStructure <T, Octree <T> > .Get(Depth, childrens)); } }
static Quadtree() { HashedRecursiveSpatialStructure <T, Quadtree <T> > .Setup(new _Setup()); }
/// <summary> /// Creates a quadtree with the specified quadtree children. /// </summary> public static Quadtree <T> Create(int Depth, Quadtree <T>[] Children) { return(HashedRecursiveSpatialStructure <T, Quadtree <T> > .Get(Depth, Children)); }
/// <summary> /// Creates a depth-0 quadtree with a single value. /// </summary> public static Quadtree <T> Singleton(T Value) { return(HashedRecursiveSpatialStructure <T, Quadtree <T> > .Get(Value)); }