Working on triangle BVH

main
Brett 2022-11-17 00:37:33 -05:00
parent 205946925b
commit 8961919bcc
1 changed files with 33 additions and 7 deletions

View File

@ -8,6 +8,7 @@
#include "engine/util/std.h"
#include "engine/types.h"
#include "engine/util/models.h"
#include <config.h>
#ifdef COMPILE_GUI
@ -62,12 +63,8 @@ namespace Raytracing {
AABB aabb;
BVHNode* left;
BVHNode* right;
int index;
int hit = 0;
BVHNode(std::vector<BVHObject> objs, AABB aabb, BVHNode* left, BVHNode* right): objs(std::move(objs)), aabb(std::move(aabb)),
left(left), right(right) {
index = count++;
}
left(left), right(right) {}
BVHHitData firstHitRayIntersectTraversal(const Ray& r, PRECISION_TYPE min, PRECISION_TYPE max);
~BVHNode() {
delete (left);
@ -101,6 +98,35 @@ namespace Raytracing {
}
};
struct TriangleBVHObject {
Triangle* ptr = nullptr;
AABB aabb;
};
struct TriangleBVHPartitionedSpace {
std::vector<TriangleBVHObject> left;
std::vector<TriangleBVHObject> right;
};
struct TriangleBVHNode {
struct BVHHitData {
TriangleBVHNode* ptr{};
AABBHitData data{};
bool hit = false;
};
std::vector<TriangleBVHObject> objs;
AABB aabb;
TriangleBVHNode* left;
TriangleBVHNode* right;
TriangleBVHNode(std::vector<TriangleBVHObject> objs, AABB aabb, TriangleBVHNode* left, TriangleBVHNode* right)
: objs(std::move(objs)), aabb(std::move(aabb)), left(left), right(right) {}
~TriangleBVHNode() {
delete (left);
delete (right);
}
};
}
#endif //STEP_2_BVH_H