ray-tracer-challenge/intersections.h
2024-08-11 19:36:48 -05:00

35 lines
653 B
C

#pragma once
#include <stdarg.h>
struct intersection {
float t;
struct shape const * object;
};
#ifndef INTERSECTIONS_MAX
#define INTERSECTIONS_MAX 1024
#endif
struct intersections {
int count;
struct intersection i[INTERSECTIONS_MAX];
};
struct intersection intersection(float t, struct shape const * const object)
{
return (struct intersection){ t, object };
}
inline static void intersections(struct intersections * intersections, int count, ...)
{
va_list ap;
va_start(ap, count);
for (int i = 0; i < count; i++) {
intersections->i[i] = va_arg(ap, struct intersection);
}
va_end(ap);
intersections->count = count;
}