summaryrefslogtreecommitdiff
path: root/src/ix3.c
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2018-11-27 23:47:46 -0800
committerVito Caputo <vcaputo@pengaru.com>2018-11-27 23:50:58 -0800
commit28c0347ab1af0adec0249788f8351b0bde06297e (patch)
tree74635d38ff8a4bf0022095391ea978ffc8c6d7bb /src/ix3.c
parentb62ceffebf1e26d7cb8e9c1edb52020a803e6713 (diff)
libix3: add ix3_reset()
This basically amounts to a pad_reset() wrapper. Also incorporated resets into the test, while fixing a stupid bug there.
Diffstat (limited to 'src/ix3.c')
-rw-r--r--src/ix3.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/ix3.c b/src/ix3.c
index b5ac3cd..29ee4e7 100644
--- a/src/ix3.c
+++ b/src/ix3.c
@@ -167,7 +167,9 @@ static void init_node(ix3_node_t *node, bb3f_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;
@@ -508,6 +510,23 @@ fail_ix3:
}
+/* Reset the index ix3 to its state as-returned by ix3_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 ix3_reset(ix3_t *ix3)
+{
+ assert(ix3);
+
+ pad_reset(ix3->node_pad);
+ pad_reset(ix3->ref_pad);
+ pad_reset(ix3->object_pad);
+
+ init_node(&ix3->root, &ix3->aabb);
+}
+
+
/* Free the index ix3 and everything associated with it */
/* Note the external objects which have been indexed are not freed */
void ix3_free(ix3_t *ix3)
© All Rights Reserved