diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2018-05-17 13:11:08 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2018-05-17 13:11:08 -0700 |
commit | eab950c0678b44912daad5e716d0f0762c7a0894 (patch) | |
tree | 33a6165240a2f333b1d17fddcc75f0dba0f96d9f | |
parent | 2ea4749161db6d8856407938911f1abfcf714b9d (diff) |
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.
-rw-r--r-- | src/ix2.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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) |