public QueryPoint ( int qx, int qy ) : |
||
qx | int | |
qy | int | |
return |
public QuadtreeNode QueryPoint (int qx, int qy) {
if (root == null) return null;
QuadtreeNodeHolder c = root;
int depth = 0;
int x = 0;
int y = 0;
while (c.node == null) {
int width = 1 << (System.Math.Min (editorHeightLog2,editorWidthLog2)-depth);
if (qx >= x + width/2) {
x = x + width/2;
if (qy >= y + width/2) {
y = y + width/2;
c = c.c2;
} else {
c = c.c1;
}
} else {
if (qy >= y + width/2) {
y = y + width/2;
c = c.c3;
} else {
c = c.c0;
}
}
depth ++;
}
return c.node;
}