-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBVH.hpp
35 lines (23 loc) · 1.03 KB
/
BVH.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
#ifndef __BVH_hpp__
#define __BVH_hpp__
#include "Common.hpp"
#include "geometry/Hittable.hpp"
#include "geometry/HittableList.hpp"
class BVHNode : public Hittable {
public:
BVHNode() {};
BVHNode(const HittableList& list, Real time0, Real time1) : BVHNode(list.objects_, 0, list.objects_.size(), time0, time1) {};
BVHNode(const std::vector<shared_ptr<Hittable>>& src_objects, size_t start, size_t end, Real time0, Real time1);
virtual bool hit( const Ray& r, Real tmin, Real tmax, HitRecord& rec) const override;
virtual bool bounding_box(Real t0, Real t1, AABB& output_box) const override;
public:
shared_ptr<Hittable> left;
shared_ptr<Hittable> right;
AABB box;
private:
};
bool box_compare(const shared_ptr<Hittable> a, const shared_ptr<Hittable> b, int axis);
bool box_x_compare(const shared_ptr<Hittable> a, const shared_ptr<Hittable> b);
bool box_y_compare(const shared_ptr<Hittable> a, const shared_ptr<Hittable> b);
bool box_z_compare(const shared_ptr<Hittable> a, const shared_ptr<Hittable> b);
#endif