public void AddNeighboursRec(List <QuadtreeNode> arr, QuadtreeNodeHolder holder, int depth, int x, int y, IntRect bounds, QuadtreeNode dontInclude) { int width = 1 << (System.Math.Min(editorHeightLog2, editorWidthLog2) - depth); var r = new IntRect(x, y, x + width, y + width); if (!IntRect.Intersects(r, bounds)) { return; } if (holder.node != null) { if (holder.node != dontInclude) { arr.Add(holder.node); } } else { AddNeighboursRec(arr, holder.c0, depth + 1, x, y, bounds, dontInclude); AddNeighboursRec(arr, holder.c1, depth + 1, x + width / 2, y, bounds, dontInclude); AddNeighboursRec(arr, holder.c2, depth + 1, x + width / 2, y + width / 2, bounds, dontInclude); AddNeighboursRec(arr, holder.c3, depth + 1, x, y + width / 2, bounds, dontInclude); } }
public void AddNeighboursRec(ListView <QuadtreeNode> arr, QuadtreeNodeHolder holder, int depth, int x, int y, IntRect bounds, QuadtreeNode dontInclude) { int num = ((int)1) << (Math.Min(this.editorHeightLog2, this.editorWidthLog2) - depth); IntRect a = new IntRect(x, y, x + num, y + num); if (IntRect.Intersects(a, bounds)) { if (holder.node != null) { if (holder.node != dontInclude) { arr.Add(holder.node); } } else { this.AddNeighboursRec(arr, holder.c0, depth + 1, x, y, bounds, dontInclude); this.AddNeighboursRec(arr, holder.c1, depth + 1, x + (num / 2), y, bounds, dontInclude); this.AddNeighboursRec(arr, holder.c2, depth + 1, x + (num / 2), y + (num / 2), bounds, dontInclude); this.AddNeighboursRec(arr, holder.c3, depth + 1, x, y + (num / 2), bounds, dontInclude); } } }