+
+int planet_search_rectangular(struct quadtree *node,
+ struct quadtree_iterator *itr)
+{
+ struct planet_search_iterator *it = qt_itr_to_planet_itr(itr);
+ struct planet *p = tree_to_planet(node);
+ int direction = 0, i;
+ int up = 0, left = 0, right = 0, down = 0;
+
+ for (i = 0; i < 2; i++) {
+ if (it->limit[i].x < p->pos.x)
+ left = 1;
+ else
+ right = 1;
+ if (it->limit[i].y < p->pos.y)
+ up = 1;
+ else
+ down = 1;
+ }
+
+ if (left && up)
+ direction |= QUADTREE_UPLEFT;
+ if (right && up)
+ direction |= QUADTREE_UPRIGHT;
+ if (left && down)
+ direction |= QUADTREE_DOWNLEFT;
+ if (right && down)
+ direction |= QUADTREE_DOWNRIGHT;
+ if (direction == (QUADTREE_UPLEFT | QUADTREE_UPRIGHT |
+ QUADTREE_DOWNLEFT | QUADTREE_DOWNRIGHT))
+ direction |= QUADTREE_SELF;
+
+ return direction;
+}
+
+void planet_draw_iterator(struct quadtree *node, struct quadtree_iterator *it)
+{
+ struct planet *p = tree_to_planet(node);
+ struct planet_search_iterator *i = qt_itr_to_planet_itr(it);
+
+ draw_planet(i->screen, p, i->cam);
+}