-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhittable.h
More file actions
33 lines (26 loc) · 854 Bytes
/
Copy pathhittable.h
File metadata and controls
33 lines (26 loc) · 854 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
#ifndef HITTABLE_H
#define HITTABLE_H
#include "rtweekend.h"
class material;
class hit_record {
public:
point3 p;
vec3 normal; // 法线
shared_ptr<material> mat;
double t; // 控制方向
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 ~hittable() = default;
// t 的区间[ray_tmin, ray_tmax]
// 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