Closed attiju closed 4 years ago
The intent is actually to continue there: maxPrimitivesInNode is a limit that says: "always split any group of more than that many primitives into two sets during BVH construction; however, if no good split can be found and there are that many or fewer, then it's ok to create a leaf node".
Regarding the loop, indeed, it's not necessary, but it allows reusing the "Create leaf BVHBuildNode" code fragment in both branches of that if (nPrimitives == 1)
test.
I know it wont make such a difference but shouldn't you stop recursion when the number of primitives in current node is equal or bellow maxPrimsInNode ?
In the current version,
end == start + 1
then the for loop is useless.I suppose you wanted the if condition to be
if (nPrimitives <= maxPrimsInNode) { ... }
https://github.com/mmp/pbrt-v3/blob/3f94503ae1777cd6d67a7788e06d67224a525ff4/src/accelerators/bvh.cpp#L248