#ifndef OBJ_H #define OBJ_H #include "ray.h" #define SPHERE(x, y, z, r) \ { \ .intersect = intersect_sphere, \ .params = { \ .sphere = { .centre = { x, y, z }, .radius = r }, \ }, \ } typedef struct { vec3_t point, normal; double t; } hit_t; typedef struct { vec3_t centre; double radius; } sphere_params_t; typedef union { sphere_params_t sphere; } obj_params_t; typedef struct { bool (*intersect)(obj_params_t params, ray_t ray, hit_t *hit_out); obj_params_t params; } obj_t; bool intersect_sphere(obj_params_t params, ray_t ray, hit_t *hit_out); #endif