private void Split() { QuadOne = new Quadtree(Owner, Top, VerticalMedian, HorizontalMedian, Right, this, MaximumContents); QuadTwo = new Quadtree(Owner, Top, VerticalMedian, Left, HorizontalMedian, this, MaximumContents); QuadThree = new Quadtree(Owner, VerticalMedian, Bottom, Left, HorizontalMedian, this, MaximumContents); QuadFour = new Quadtree(Owner, VerticalMedian, Bottom, HorizontalMedian, Right, this, MaximumContents); List <CircleRigidBody> toInstert = Contents; Contents = new List <CircleRigidBody>(); foreach (CircleRigidBody circle in toInstert) { Insert(circle); } }
public Quadtree(CircleRigidBody owner, float top, float bottom, float left, float right, Quadtree parent = null, int maximumContents = 5) { MaximumContents = maximumContents; Contents = new List <CircleRigidBody>(); ToRectify = new List <CircleRigidBody>(); Owner = owner; Top = top; Bottom = bottom; Left = left; Right = right; NearBoundry = FarthestCorner() >= Owner.Radius; }