-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhittable.h
More file actions
39 lines (30 loc) · 882 Bytes
/
Copy pathhittable.h
File metadata and controls
39 lines (30 loc) · 882 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
35
36
37
38
39
//
// Created by 13240 on 2025/10/14.
//
#ifndef SIMPLE_SOFTRT_HITTABLE_H
#define SIMPLE_SOFTRT_HITTABLE_H
#include "aabb.h"
class material;
class hit_record {
public:
point3 p;
vec3 normal;
std::shared_ptr<material> mat;
double t;
double u;
double v;
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;
virtual bool hit(const ray &r, interval ray_t, hit_record &rec) const = 0;
virtual aabb bounding_box() const = 0;
};
#endif //SIMPLE_SOFTRT_HITTABLE_H