-
Notifications
You must be signed in to change notification settings - Fork 0
/
hittable.hpp
41 lines (32 loc) · 905 Bytes
/
hittable.hpp
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
40
41
#ifndef HITTABLE_H
#define HITTABLE_H
#include "ray.hpp"
#include "vec2.hpp"
class hit_record
{
public:
point3 p;
vec3 normal;
double t;
vec2 uv;
shadingModel* material;
bool front_face;
vec3 d;
int id;
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;
}
};
class hittable {
public:
virtual bool hit(const ray& cam_ray, double t_min, double t_max, hit_record& rec) = 0;
point3 get_lower_extent() { return this->lower_extent; }
point3 get_upper_extent() { return this->upper_extent; }
protected:
point3 lower_extent;
point3 upper_extent;
virtual void calculate_extents() = 0;
};
#endif