continue;
}
- printf("\nMove node %p\n", &p->tree);
-
tree_parent = quadtree_del(&p->tree, &planet_ops);
p->tree.pos = new_pos;
quadtree_add(tree_parent, &p->tree, &planet_ops);
if (p->to_be_deleted) {
list_del(&p->list);
- printf("Permanently removing node %p\n", &p->tree);
tree_parent = quadtree_del(&p->tree, &planet_ops);
free(p);
return tree_to_planet(tree_parent);
directions = quadrants_to_search(tree, corner);
- printf("Starting from parent %p (%f %f), target (%f %f), %x\n", tree,
- tree->pos.x, tree->pos.y, pos->x, pos->y, directions);
-
for (i = 0; i < 4; i++) {
if (!tree->child[i])
continue;
vector_sub(pos, &node->pos, &tmp);
dist = vector_abs(&tmp);
- printf("%p: (%f %f)dist: %f, distance: %f\n",
- node, node->pos.x, node->pos.y,
- dist, distance);
if (!nearest || dist < distance) {
nearest = node;
distance = dist;
- printf("Choosing nearest\n");
}
}
corner[1].x, corner[1].y);
return NULL;
}
- printf("%d: Returning %p\n",__LINE__, nearest);
return nearest;
}
vector_sub(pos, &nearest->pos, &sub);
dist = vector_abs(&sub);
- printf("Setting nearest from %d\n", i);
continue;
}
node = quadtree_find_nearest(tree->child[i],
nearest = node;
dist = dist2;
}
- printf("Re-setting nearest from %d\n", i);
}
out:
- printf("%d: Returning %p\n", __LINE__, nearest);
return nearest;
}