-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhitable.hpp
More file actions
35 lines (29 loc) · 831 Bytes
/
hitable.hpp
File metadata and controls
35 lines (29 loc) · 831 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
#ifndef HITABLEH
#define HITABLEH
#include "ray.hpp"
#include "aabb.hpp"
class material;
struct hit_record {
float t;
vec3 p;
vec3 normal;
material* mat_ptr;
float u;
float v;
};
class hitable {
public:
__device__ virtual bool hit(const ray& r, float t_min, float t_max, hit_record& rec) const = 0;
__device__ virtual bool bounding_box(float t0, float t1, aabb& box) const = 0;
material* mat_ptr;
};
__device__ aabb surrounding_box(aabb box0, aabb box1) {
vec3 smallBox(fmin(box0.minPoint().x(), box1.minPoint().x()),
fmin(box0.minPoint().y(), box1.minPoint().y()),
fmin(box0.minPoint().z(), box1.minPoint().z()));
vec3 big(fmax(box0.maxPoint().x(), box1.maxPoint().x()),
fmax(box0.maxPoint().y(), box1.maxPoint().y()),
fmax(box0.maxPoint().z(), box1.maxPoint().z()));
return aabb(smallBox, big);
}
#endif