Add front/back face detection

This commit is contained in:
Camden Dixie O'Brien
2025-09-23 15:35:26 +01:00
parent 77723aefa0
commit 6eb4da9e06
3 changed files with 26 additions and 12 deletions

View File

@@ -14,6 +14,7 @@
typedef struct {
vec3_t point, normal;
double t;
bool front;
} hit_t;
typedef struct {
@@ -25,11 +26,17 @@ 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 {
bool (*intersect)(obj_params_t params, ray_t ray, hit_t *hit_out);
intersect_fn_t *intersect;
obj_params_t params;
} obj_t;
bool intersect_sphere(obj_params_t params, ray_t ray, hit_t *hit_out);
bool intersect_sphere(
obj_params_t params, ray_t ray, hit_t *hit_out, double t_min,
double t_max);
#endif