summaryrefslogtreecommitdiffstats
path: root/libdimension/sphere.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/sphere.c
parentc2066966bbf74062c18e8a324996bf88c769362d (diff)
downloaddimension-708954192219feead526f84c0c8bdb29088aeae0.tar.xz
objects: Use a vtable to shrink object structs.
Diffstat (limited to 'libdimension/sphere.c')
-rw-r--r--libdimension/sphere.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/libdimension/sphere.c b/libdimension/sphere.c
index 821113d..105d8d6 100644
--- a/libdimension/sphere.c
+++ b/libdimension/sphere.c
@@ -58,13 +58,17 @@ dmnsn_sphere_inside_fn(const dmnsn_object *sphere, dmnsn_vector point)
return point.x*point.x + point.y*point.y + point.z*point.z < 1.0;
}
-/* Allocate a new sphere */
+/** Torus vtable. */
+static const dmnsn_object_vtable dmnsn_sphere_vtable = {
+ .intersection_fn = dmnsn_sphere_intersection_fn,
+ .inside_fn = dmnsn_sphere_inside_fn,
+};
+
dmnsn_object *
dmnsn_new_sphere(dmnsn_pool *pool)
{
dmnsn_object *sphere = dmnsn_new_object(pool);
- sphere->intersection_fn = dmnsn_sphere_intersection_fn;
- sphere->inside_fn = dmnsn_sphere_inside_fn;
+ sphere->vtable = &dmnsn_sphere_vtable;
sphere->bounding_box.min = dmnsn_new_vector(-1.0, -1.0, -1.0);
sphere->bounding_box.max = dmnsn_new_vector(1.0, 1.0, 1.0);
return sphere;