nori/include/nori/octree.h

27 lines
724 B
C++

#pragma once
#include <nori/mesh.h>
#include <vector>
NORI_NAMESPACE_BEGIN
class Octree {
public:
// Members
BoundingBox3f *bbox;
Mesh *mesh;
std::vector<Octree*> children;
std::vector<uint32_t> triangles;
// Methods
explicit Octree(BoundingBox3f *bbox, Mesh *mesh, std::vector<uint32_t> triangles) : bbox(bbox), mesh(mesh), triangles(triangles) {
children = std::vector<Octree*>(8, nullptr);
}
static Octree *build(BoundingBox3f *bbox, Mesh *mesh, std::vector<uint32_t> *triangles, int recursionDepth = 0);
uint32_t getIntersectingTriangle(Ray3f &ray, Intersection &its, bool shadowRay);
BoundingBox3f getBoundingBox() const { return *bbox; }
};
NORI_NAMESPACE_END