public void SplitUp() { TopRight = pool.Get(WorldPosition.Lerp(Quad.Center, Quad.TopRight, 0.5), Quad.HalfDimension * 0.5, CurrentHeight + 1, this); TopLeft = pool.Get(WorldPosition.Lerp(Quad.Center, Quad.TopLeft, 0.5), Quad.HalfDimension * 0.5, CurrentHeight + 1, this); BottomRight = pool.Get(WorldPosition.Lerp(Quad.Center, Quad.BottomRight, 0.5), Quad.HalfDimension * 0.5, CurrentHeight + 1, this); BottomLeft = pool.Get(WorldPosition.Lerp(Quad.Center, Quad.BottomLeft, 0.5), Quad.HalfDimension * 0.5, CurrentHeight + 1, this); for (int i = Agents.Count - 1; i >= 0; i--) { AddObjectToSubTrees(Agents[i]); Agents.Remove(Agents[i]); } }
public QuadTree(WorldPosition position, Size size, int poolSize, int nodeCapacity, int maxDepth) { pool = new QuadTreePool(this, poolSize, nodeCapacity, maxDepth); RootNode = pool.Get(position, size.Width * 0.5, 0, null); }