-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhittable.h
More file actions
34 lines (27 loc) · 780 Bytes
/
hittable.h
File metadata and controls
34 lines (27 loc) · 780 Bytes
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
#ifndef HITTABLE_H
#define HITTABLE_H
#include "vec3.h"
#include "ray.h"
#include "interval.h"
#include <memory>
#include "rtweekend.h"
class material;
class hit_record {
public:
point3 p;
vec3 normal;
double t;
shared_ptr<material> mat;
bool front_face;
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 bool hit(const ray& r, interval ray_t, hit_record& rec) const = 0;
};
#endif