Files
batomorph/include/obj.h
2025-09-23 15:35:26 +01:00

43 lines
707 B
C

#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;
bool front;
} hit_t;
typedef struct {
vec3_t centre;
double radius;
} sphere_params_t;
typedef union {
sphere_params_t sphere;
} obj_params_t;
typedef bool intersect_fn_t(
obj_params_t params, ray_t ray, hit_t *hit_out, double t_min,
double t_max);
typedef struct {
intersect_fn_t *intersect;
obj_params_t params;
} obj_t;
bool intersect_sphere(
obj_params_t params, ray_t ray, hit_t *hit_out, double t_min,
double t_max);
#endif