Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Courses
Scotty3D
Commits
42d39f97
Commit
42d39f97
authored
Apr 07, 2021
by
TheNumbat
Browse files
use is leaf in bvh
parent
24b1cee1
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/rays/bvh.h
View file @
42d39f97
...
...
@@ -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
>
;
};
...
...
src/student/bvh.inl
View file @
42d39f97
...
...
@@ -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 {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment