diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2018-11-27 01:09:06 -0800 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2018-11-27 01:09:06 -0800 |
commit | 38b70d0dc5c39e6278bf30c67e1e12f7ac8c1fa0 (patch) | |
tree | b75e952584796461aa11d8db1e3e991d7d3e024b /src/ix2.c | |
parent | 4289caa8e9c4802c307bfb69245d8cad956066db (diff) |
libpad: add ix2_reset()
This basically amounts to adding a pad_reset() wrapper.
Also incorporated resets into the test, while fixing a stupid
bug there.
Diffstat (limited to 'src/ix2.c')
-rw-r--r-- | src/ix2.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -150,7 +150,9 @@ static void init_node(ix2_node_t *node, bb2f_t *aabb) assert(node); assert(aabb); + node->children = NULL; INIT_LIST_HEAD(&node->objects); + node->n_objects = 0; node->center.x = aabb->min.x; node->center.y = aabb->min.y; @@ -450,6 +452,23 @@ fail_ix2: } +/* Reset the index ix2 to its state as-returned by ix2_new() + * + * Note this doesn't free memory, it just discards the index while keeping all + * the memory around in the caches for efficient reuse. + */ +void ix2_reset(ix2_t *ix2) +{ + assert(ix2); + + pad_reset(ix2->node_pad); + pad_reset(ix2->ref_pad); + pad_reset(ix2->object_pad); + + init_node(&ix2->root, &ix2->aabb); +} + + /* Free the index ix2 and everything associated with it */ /* Note the external objects which have been indexed are not freed */ void ix2_free(ix2_t *ix2) |