Create obj module for scene objects

This commit is contained in:
2025-09-23 15:36:08 +01:00
parent f7e71da27f
commit 47fcd8a11e
5 changed files with 85 additions and 26 deletions

35
include/obj.h Normal file
View File

@@ -0,0 +1,35 @@
#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