More boilerplate
This commit is contained in:
+34
-1
@@ -1,5 +1,6 @@
|
||||
#include "BVH.h"
|
||||
#include <list>
|
||||
#include <algorithm>
|
||||
#include <ranges>
|
||||
|
||||
void BVH::addModel(PModel model, glm::mat4 transform)
|
||||
{
|
||||
@@ -54,3 +55,35 @@ void BVH::generate()
|
||||
}
|
||||
hierarchy = std::move(pendingNodes[0]);
|
||||
}
|
||||
|
||||
std::optional<IntersectionInfo> BVH::traceRay(Ray ray)
|
||||
{
|
||||
}
|
||||
|
||||
std::vector<IntersectionInfo> BVH::generateIntersections(PNode& currentNode, Ray ray)
|
||||
{
|
||||
if(!currentNode->aabb.intersects(ray))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
if(currentNode->model != nullptr)
|
||||
{
|
||||
auto result = currentNode->model->intersect(ray);
|
||||
if(result.has_value())
|
||||
{
|
||||
return {*result};
|
||||
}
|
||||
else
|
||||
{
|
||||
return {};
|
||||
}
|
||||
}
|
||||
auto leftResults = generateIntersections(currentNode->left, ray);
|
||||
auto rightResults = generateIntersections(currentNode->right, ray);
|
||||
|
||||
for(auto it : rightResults)
|
||||
{
|
||||
leftResults.push_back(it);
|
||||
}
|
||||
return leftResults;
|
||||
}
|
||||
Reference in New Issue
Block a user