diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2018-05-18 12:42:20 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2018-05-18 12:42:20 -0700 |
commit | bbda6b11ed13005a1927a4fd5896d7e87456b0e7 (patch) | |
tree | 246d9727f8197180c2f5be1d160c19b8e8030a0f | |
parent | 1824156efa21590a7f362ff8c786f03f5ba0f51c (diff) |
libix2: count the last hit in stopped searches
I may need to add another status code to control wether the stop
should be counted. For now, all my use cases wanted the count.
-rw-r--r-- | src/ix2.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -543,8 +543,10 @@ unsigned ix2_search_by_point(ix2_t *ix2, v2f_t *point, ix2_search_cb cb, void *c ix2_object_t *o = ref->object; r = cb(cb_context, o, &o->position, &o->aabb, o->object); - if (r == IX2_SEARCH_STOP) + if (r == IX2_SEARCH_STOP) { + n_hits++; break; + } if (r == IX2_SEARCH_IGNORE) continue; @@ -641,8 +643,10 @@ unsigned ix2_search_by_aabb(ix2_t *ix2, float x, float y, aabb_t *search_aabb, i ix2_search_status_t r; r = cb(cb_context, o, &o->position, &o->aabb, o->object); - if (r == IX2_SEARCH_STOP) + if (r == IX2_SEARCH_STOP) { + n_hits++; break; + } if (r == IX2_SEARCH_IGNORE) continue; |