public QuadTree(Rectangle bounds, int depth) { mDepth = depth; mTopLeft = mTopRight = mBottomLeft = mBottomRight = null; mBounds = bounds; mPoints = new List<DblPoint2>(); }
private void Split() { var w2 = mBounds.Width / 2.0; var h2 = mBounds.Height / 2.0; mBottomLeft = new QuadTree(new Rectangle(mBounds.X , mBounds.Y , w2, h2), mDepth + 1); mBottomRight = new QuadTree(new Rectangle(mBounds.X + w2, mBounds.Y , w2, h2), mDepth + 1); mTopLeft = new QuadTree(new Rectangle(mBounds.X , mBounds.Y + h2, w2, h2), mDepth + 1); mTopRight = new QuadTree(new Rectangle(mBounds.X + w2, mBounds.Y + h2, w2, h2), mDepth + 1); //Riaggiungili tutti sui figli e poi svuota foreach (var p in mPoints) AddPoint(p); mPoints.Clear(); }