Create material abstraction

This commit is contained in:
Camden Dixie O'Brien
2025-09-21 18:21:53 +01:00
parent aabfe7924d
commit d7667fa266
8 changed files with 84 additions and 26 deletions

View File

@@ -1,22 +1,18 @@
#ifndef OBJ_H
#define OBJ_H
#include "material.h"
#include "ray.h"
#define SPHERE(x, y, z, r) \
#define SPHERE(x, y, z, r, m) \
{ \
.intersect = intersect_sphere, \
.material = m, \
.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;
@@ -32,6 +28,7 @@ typedef bool intersect_fn_t(
typedef struct {
intersect_fn_t *intersect;
material_t material;
obj_params_t params;
} obj_t;