-
Notifications
You must be signed in to change notification settings - Fork 0
/
hittable.h
35 lines (27 loc) · 825 Bytes
/
hittable.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef HITTABLE_H
#define HITTABLE_H
#include "ray.h"
#include "interval.h"
#include "rtweekend.h"
class material;
class hit_record {
public:
point3 p;
vec3 normal;
double t;
bool front_face;
shared_ptr<material> mat;
void set_face_normal(const ray& r, const vec3& outward_normal) {
// Sets the hit record normal vector.
// NOTE: the parameter `outward_normal` is assumed to have unit length.
front_face = dot(r.direction(), outward_normal) < 0;
normal = front_face ? outward_normal : -outward_normal;
}
};
class hittable {
public:
virtual ~hittable() = default;
virtual bool hit(const ray& r, double ray_tmin, double ray_tmax, hit_record& rec) const = 0;
virtual bool hit(const ray& r, interval ray_t, hit_record& rec) const = 0;
};
#endif