Skip to content
This repository was archived by the owner on Nov 22, 2022. It is now read-only.

Commit 0324fef

Browse files
ToJansTom Janssens
andauthored
Fix infinite recursive loop in BVH building (#81)
When all primitive centroids are equal during a recursive BVH building step, it results in a recursive loop. This fix detects this case and returns a leaf node instead. Co-authored-by: Tom Janssens <tom@corebvba.be>
1 parent e6d951c commit 0324fef

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/renderer/bvhAccel.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ function recursiveBuild(primitiveInfo, start, end) {
149149
}
150150
const dim = maximumExtent(centroidBounds);
151151

152+
if (centroidBounds.max[dim] === centroidBounds.min[dim]) {
153+
return makeLeafNode(primitiveInfo.slice(start, end), bounds);
154+
}
155+
152156
let mid = Math.floor((start + end) / 2);
153157

154158
// middle split method

0 commit comments

Comments
 (0)