static void validate_subtree(const struct quadtree *node)
{
- int i;
+ int i, dir;
long int children;
children = 0;
}
}
+ dir = quadtree_compare(node, node->child[i]);
+
+ if (dir != i) {
+ printf("%s:%d Fatal! Spatial inconsistency detected "
+ "at child %d in node %p\n"
+ "parent: (%f %f), child (%f %f), "
+ "dir %d != %d\n",
+ __func__, __LINE__, i, node,
+ node->pos.x, node->pos.y,
+ node->child[i]->pos.x, node->child[i]->pos.y,
+ dir, i);
+ fflush(stdout);
+ trap();
+ }
+
children += node->child[i]->children + 1;
validate_subtree(node->child[i]);