2020-06-03 21:49:20 +00:00
|
|
|
#ifndef HITTABLE_H
|
|
|
|
#define HITTABLE_H
|
|
|
|
|
|
|
|
#include "ray.h"
|
|
|
|
|
|
|
|
struct hit_record {
|
|
|
|
Point3 p;
|
|
|
|
Vec3 normal;
|
|
|
|
double t;
|
2020-06-03 22:15:32 +00:00
|
|
|
bool front_face;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2020-06-03 21:49:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Hittable {
|
|
|
|
public:
|
2020-06-03 22:15:32 +00:00
|
|
|
virtual bool hit(const Ray &r, double tmin, double tmax, hit_record &rec) const = 0;
|
|
|
|
};
|
2020-06-03 21:49:20 +00:00
|
|
|
|
|
|
|
#endif // HITTABLE_H
|