summaryrefslogtreecommitdiffstats
path: root/libdimension/cube.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2014-06-06 14:14:00 -0400
committerTavian Barnes <tavianator@tavianator.com>2014-06-06 14:14:00 -0400
commit708954192219feead526f84c0c8bdb29088aeae0 (patch)
treebfe241506d38559533016b92136f8d924dfe6fee /libdimension/cube.c
parentc2066966bbf74062c18e8a324996bf88c769362d (diff)
downloaddimension-708954192219feead526f84c0c8bdb29088aeae0.tar.xz
objects: Use a vtable to shrink object structs.
Diffstat (limited to 'libdimension/cube.c')
-rw-r--r--libdimension/cube.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libdimension/cube.c b/libdimension/cube.c
index 8a1a503..d4c9d5b 100644
--- a/libdimension/cube.c
+++ b/libdimension/cube.c
@@ -129,13 +129,18 @@ dmnsn_cube_inside_fn(const dmnsn_object *cube, dmnsn_vector point)
&& point.z > -1.0 && point.z < 1.0;
}
+/** Cube vtable. */
+static const dmnsn_object_vtable dmnsn_cube_vtable = {
+ .intersection_fn = dmnsn_cube_intersection_fn,
+ .inside_fn = dmnsn_cube_inside_fn,
+};
+
/* Allocate a new cube object */
dmnsn_object *
dmnsn_new_cube(dmnsn_pool *pool)
{
dmnsn_object *cube = dmnsn_new_object(pool);
- cube->intersection_fn = dmnsn_cube_intersection_fn;
- cube->inside_fn = dmnsn_cube_inside_fn;
+ cube->vtable = &dmnsn_cube_vtable;
cube->bounding_box.min = dmnsn_new_vector(-1.0, -1.0, -1.0);
cube->bounding_box.max = dmnsn_new_vector(1.0, 1.0, 1.0);
return cube;