summaryrefslogtreecommitdiff
path: root/src/ix3.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ix3.c')
-rw-r--r--src/ix3.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/src/ix3.c b/src/ix3.c
index 29ee4e7..ea8e46d 100644
--- a/src/ix3.c
+++ b/src/ix3.c
@@ -676,13 +676,22 @@ unsigned ix3_search_by_point(ix3_t *ix3, v3f_t *point, ix3_search_cb cb, void *c
ix3_object_t *o = ref->object;
r = cb(cb_context, o, &o->position, &o->aabb, o->object);
- if (r == IX3_SEARCH_STOP) {
+ switch (r) {
+ case IX3_SEARCH_STOP_HIT:
+ n_hits++;
+
+ case IX3_SEARCH_STOP_MISS:
+ return n_hits;
+
+ case IX3_SEARCH_MORE_HIT:
n_hits++;
- break;
- }
- if (r == IX3_SEARCH_IGNORE)
+ case IX3_SEARCH_MORE_MISS:
continue;
+
+ default:
+ assert(0);
+ }
}
n_hits++;
@@ -772,22 +781,30 @@ unsigned ix3_search_by_aabb(ix3_t *ix3, v3f_t *search_position, v3f_t *search_or
ix3_search_status_t r;
r = cb(cb_context, o, &o->position, &o->aabb, o->object);
- if (r == IX3_SEARCH_STOP) {
+ switch (r) {
+ case IX3_SEARCH_STOP_HIT:
n_hits++;
- break;
- }
- if (r == IX3_SEARCH_IGNORE)
+ case IX3_SEARCH_STOP_MISS:
+ /* XXX: this is necessary, the hits nodes must be kept movable */
+ list_for_each_entry_safe(o, _o, &hits, hits)
+ list_del_init(&o->hits);
+
+ return n_hits;
+
+ case IX3_SEARCH_MORE_HIT:
+ n_hits++;
+
+ case IX3_SEARCH_MORE_MISS:
continue;
+
+ default:
+ assert(0);
+ }
}
n_hits++;
}
- /* just in case the search was aborted, finish deleting these nodes */
- /* FIXME: this whole hit list thing is pretty janky */
- list_for_each_entry_safe(o, _o, &hits, hits)
- list_del_init(&o->hits);
-
return n_hits;
}
© All Rights Reserved