]> git.itanic.dy.fi Git - sdl-planets/commitdiff
Revert "Try to optimze"
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Mon, 12 Apr 2010 15:54:08 +0000 (18:54 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Mon, 12 Apr 2010 15:54:08 +0000 (18:54 +0300)
This reverts commit 66ec6620125badde86f08fabb0a99226da922ee6.

Conflicts:

quadtree.c

quadtree.c

index abf7c1b979fe92bb324e70bdce76dd982abed0da..8efd8ad7a465b6a682ff5859350b345e653a02f7 100644 (file)
@@ -148,39 +148,22 @@ _quadtree_reposition_reqursively(struct quadtree *root,
                                 struct quadtree *node,
                                 struct quadtree_ops *ops)
 {
-       int i, max_child, max_child_idx;
+       int i;
 
        validate_tree(node);
 
        /* First remove all children, if any */
-       while (1) {
-
-               /*
-                * Attempt to move from the middle of the most dense
-                * branch. That might increase the chances of creating
-                * a tree with better balance.
-                */
-
-               max_child = -1;
-               max_child_idx = -1;
-               for (i = 0; i < 4; i++) {
-                       if (!node->child[i])
-                               continue;
-
-                       if (node->child[i]->children > max_child) {
-                               max_child = node->child[i]->children;
-                               max_child_idx = i;
-                       }
 
-               }
+       for (i = 0; i < 4; i++) {
+               if (!node->child[i])
+                       continue;
 
-               if (max_child < 0)
-                       break;
+               if (node->child[i] == node ||
+                   node->child[i] == node->parent)
+                       trap();
 
-               _quadtree_reposition_reqursively(root,
-                                                node->child[max_child_idx],
-                                                ops);
-               node->child[max_child_idx] = 0;
+               _quadtree_reposition_reqursively(root, node->child[i], ops);
+               node->child[i] = 0;
        }
 
        /* There are no children left, reset stats */