snoopy/include/hittable.h

28 lines
608 B
C
Raw Permalink Normal View History

2020-06-06 18:38:36 +02:00
#pragma once
2020-06-07 00:59:30 +02:00
#include "rtweekend.h"
2020-06-06 18:38:36 +02:00
#include "ray.h"
2020-06-07 00:59:30 +02:00
class material;
2020-06-06 18:38:36 +02:00
struct hit_record
{
2020-06-07 00:59:30 +02:00
point3 p;
vec3 normal;
shared_ptr<material> mat_ptr;
double t;
bool front_face;
2020-06-06 18:38:36 +02:00
inline void set_face_normal(const ray& r, const vec3& outward_normal)
{
front_face = dot(r.direction(), outward_normal) < 0;
normal = front_face ? outward_normal : -outward_normal;
}
};
class hittable
{
public:
virtual bool hit(const ray& r, double tMin, double tMax, hit_record& rec) const = 0;
};