From bbda6b11ed13005a1927a4fd5896d7e87456b0e7 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Fri, 18 May 2018 12:42:20 -0700 Subject: 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. --- src/ix2.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/ix2.c') diff --git a/src/ix2.c b/src/ix2.c index 79aa7ab..dad06b1 100644 --- a/src/ix2.c +++ b/src/ix2.c @@ -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; -- cgit v1.2.3