diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2014-06-07 14:15:06 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2014-06-07 14:30:26 -0400 |
commit | a79085ab984979dbf4f78545f7592c8b47e4a794 (patch) | |
tree | e2518532db860db8ba59878ecd6d0d4b60f0b5c4 /libdimension/tests | |
parent | 708954192219feead526f84c0c8bdb29088aeae0 (diff) | |
download | dimension-a79085ab984979dbf4f78545f7592c8b47e4a794.tar.xz |
objects: Refactor how bounding and initialization work.
Diffstat (limited to 'libdimension/tests')
-rw-r--r-- | libdimension/tests/prtree.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/libdimension/tests/prtree.c b/libdimension/tests/prtree.c index a7db68e..fdc5878 100644 --- a/libdimension/tests/prtree.c +++ b/libdimension/tests/prtree.c @@ -58,6 +58,20 @@ dmnsn_randomize_bounding_box(dmnsn_object *object) object->bounding_box.max = dmnsn_vector_max(a, b); } +static const dmnsn_object_vtable dmnsn_fake_vtable = { + .intersection_fn = dmnsn_fake_intersection_fn, +}; + +static dmnsn_object * +dmnsn_new_fake_object(dmnsn_pool *pool) +{ + dmnsn_object *object = dmnsn_new_object(pool); + dmnsn_randomize_bounding_box(object); + object->vtable = &dmnsn_fake_vtable; + object->trans_inv = dmnsn_identity_matrix(); + return object; +} + int main(void) { @@ -70,10 +84,7 @@ main(void) dmnsn_array *objects = DMNSN_PALLOC_ARRAY(pool, dmnsn_object *); for (size_t i = 0; i < nobjects; ++i) { - dmnsn_object *object = dmnsn_new_object(pool); - dmnsn_randomize_bounding_box(object); - object->intersection_fn = dmnsn_fake_intersection_fn; - object->trans_inv = dmnsn_identity_matrix(); + dmnsn_object *object = dmnsn_new_fake_object(pool); dmnsn_array_push(objects, &object); } |