Implement BVH
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
#ifndef HITTABLE_LIST_H
|
||||
#define HITTABLE_LIST_H
|
||||
|
||||
#include "aabb.h"
|
||||
#include "hittable.h"
|
||||
#include "rayTracer.h"
|
||||
#include <vector>
|
||||
|
||||
class hittableList : public hittable {
|
||||
private:
|
||||
aabb bBox;
|
||||
|
||||
public:
|
||||
std::vector<shared_ptr<hittable>> objects;
|
||||
|
||||
@@ -20,6 +24,7 @@ class hittableList : public hittable {
|
||||
|
||||
void add(shared_ptr<hittable> object) {
|
||||
objects.push_back(object);
|
||||
bBox = aabb(bBox, object->boundingBox());
|
||||
}
|
||||
|
||||
bool hit (const ray& r, interval rayT, hitRecord& rec) const override {
|
||||
@@ -38,6 +43,10 @@ class hittableList : public hittable {
|
||||
|
||||
return hitAnything;
|
||||
}
|
||||
|
||||
aabb boundingBox() const override {
|
||||
return bBox;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user