36 lines
706 B
C
36 lines
706 B
C
#pragma once
|
|
|
|
#include "math.h"
|
|
#include "matrices.h"
|
|
#include "materials.h"
|
|
#include "shapes.h"
|
|
#include "rays.h"
|
|
#include "intersections.h"
|
|
|
|
inline static struct shape plane()
|
|
{
|
|
return (struct shape){
|
|
mat4x4_identity(),
|
|
material(),
|
|
SHAPE_PLANE,
|
|
};
|
|
}
|
|
|
|
inline static struct tuple plane_normal_at(struct tuple local_point)
|
|
{
|
|
return vector(0.0f, 1.0f, 0.0f);
|
|
}
|
|
|
|
inline static void plane_intersect(struct shape const * const s, struct ray local_ray, struct intersections * intersections)
|
|
{
|
|
if (fabsf(local_ray.direction.y) < epsilon) {
|
|
return;
|
|
}
|
|
|
|
float t = -local_ray.origin.y / local_ray.direction.y;
|
|
|
|
intersections->i[intersections->count++] = intersection(t, s);
|
|
|
|
return;
|
|
}
|