Commit 42d39f97 authored by TheNumbat's avatar TheNumbat
Browse files

use is leaf in bvh

parent 24b1cee1
......@@ -31,9 +31,11 @@ public:
private:
class Node {
BBox bbox;
size_t start, size, l, r;
// A node is a leaf if l == r, since all interior nodes must have distinct children
bool is_leaf() const;
friend class BVH<Primitive>;
};
......
......@@ -77,6 +77,8 @@ template<typename Primitive> BVH<Primitive> BVH<Primitive>::copy() const {
}
template<typename Primitive> bool BVH<Primitive>::Node::is_leaf() const {
// A node is a leaf if l == r, since all interior nodes must have distinct children
return l == r;
}
......@@ -145,7 +147,7 @@ size_t BVH<Primitive>::visualize(GL::Lines& lines, GL::Lines& active, size_t lev
edge(Vec3{max.x, min.y, min.z}, Vec3{max.x, max.y, min.z});
edge(Vec3{max.x, min.y, min.z}, Vec3{max.x, min.y, max.z});
if(node.l && node.r) {
if(!node.is_leaf()) {
tstack.push({node.l, lvl + 1});
tstack.push({node.r, lvl + 1});
} else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment