public FlxQuadTree(float X, float Y, float Width, float Height, FlxQuadTree Parent = null)
: base(X, Y, Width, Height)
{
_headA = _tailA = new FlxList();
_headB = _tailB = new FlxList();
//Copy the parent's children (if there are any)
if(Parent != null)
{
FlxList iterator;
FlxList ot;
if(Parent._headA.Object != null)
{
iterator = Parent._headA;
while(iterator != null)
{
if(_tailA.Object != null)
{
ot = _tailA;
_tailA = new FlxList();
ot.next = _tailA;
}
_tailA.Object = iterator.Object;
iterator = iterator.next;
}
}
if(Parent._headB.Object != null)
{
iterator = Parent._headB;
while(iterator != null)
{
if(_tailB.Object != null)
{
ot = _tailB;
_tailB = new FlxList();
ot.next = _tailB;
}
_tailB.Object = iterator.Object;
iterator = iterator.next;
}
}
}
else
_min = (uint)(base.Width + base.Height) / (2 * divisions);
_canSubdivide = (base.Width > _min) || (base.Height > _min);
//Set up comparison/sort helpers
_northWestTree = null;
_northEastTree = null;
_southEastTree = null;
_southWestTree = null;
_leftEdge = base.X;
_rightEdge = base.X + base.Width;
_halfWidth = base.Width / 2;
_midpointX = _leftEdge + _halfWidth;
_topEdge = base.Y;
_bottomEdge = base.Y + base.Height;
_halfHeight = base.Height / 2;
_midpointY = _topEdge + _halfHeight;
}