Implement BVH

This commit is contained in:
CJSatnarine
2024-07-08 17:31:04 -04:00
parent 5ca33d1762
commit 80f3aff65d
18 changed files with 81908 additions and 351689 deletions

View File

@@ -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