diff options
Diffstat (limited to 'src/ix2.c')
-rw-r--r-- | src/ix2.c | 45 |
1 files changed, 31 insertions, 14 deletions
@@ -612,17 +612,26 @@ unsigned ix2_search_by_point(ix2_t *ix2, v2f_t *point, ix2_search_cb cb, void *c continue; if (cb) { - ix2_search_status_t r; ix2_object_t *o = ref->object; + ix2_search_status_t r; r = cb(cb_context, o, &o->position, &o->aabb, o->object); - if (r == IX2_SEARCH_STOP) { + switch (r) { + case IX2_SEARCH_STOP_HIT: n_hits++; - break; - } - if (r == IX2_SEARCH_IGNORE) + case IX2_SEARCH_STOP_MISS: + return n_hits; + + case IX2_SEARCH_MORE_HIT: + n_hits++; + + case IX2_SEARCH_MORE_MISS: continue; + + default: + assert(0); + } } n_hits++; @@ -712,22 +721,30 @@ unsigned ix2_search_by_aabb(ix2_t *ix2, v2f_t *search_position, v2f_t *search_or ix2_search_status_t r; r = cb(cb_context, o, &o->position, &o->aabb, o->object); - if (r == IX2_SEARCH_STOP) { + switch (r) { + case IX2_SEARCH_STOP_HIT: + n_hits++; + + case IX2_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 IX2_SEARCH_MORE_HIT: n_hits++; - break; - } - if (r == IX2_SEARCH_IGNORE) + case IX2_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; } |