From eab950c0678b44912daad5e716d0f0762c7a0894 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Thu, 17 May 2018 13:11:08 -0700 Subject: libix2: support default on NULL AABB in ix2_new() The -1,-1...1,1 AABB seems so likely to be used, make it the default used when supplying a NULL for the root AABB. --- src/ix2.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/ix2.c') diff --git a/src/ix2.c b/src/ix2.c index fcdeb79..28c4c11 100644 --- a/src/ix2.c +++ b/src/ix2.c @@ -368,12 +368,17 @@ _fail: } -/* Create a new ix2 index with bounds aabb, splitting nodes > max_per_node until max_depth */ +/* Create a new ix2 index with bounds aabb, splitting nodes > max_per_node until max_depth + * If the supplied aabb is NULL, a default one of -1,-1...1,1 is used. + * Returns NULL on failure. + */ ix2_t * ix2_new(aabb_t *aabb, unsigned max_per_node, unsigned max_depth) { + aabb_t default_aabb = {{-1.f, -1.f}, {1.f, 1.f}}; ix2_t *ix2; - assert(aabb); + if (!aabb) + aabb = &default_aabb; ix2 = calloc(1, sizeof(ix2_t)); if (!ix2) -- cgit v1.2.3