summaryrefslogtreecommitdiffstats
path: root/libdimension/sphere.c
diff options
context:
space:
mode:
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;