Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Found a bug in BVH8_CPU CombineLeafs when number of triangles in BLAS… #138

Merged
merged 1 commit into from
Mar 3, 2025

Conversation

romainaugier
Copy link
Contributor

… <= 4, and proposed a simple workaround for now

When using the BVH8_CPU, I found that if you have less than 5 triangles in your BLAS, then, in the CombineLeafs function, there is an infinite loop because since there is an empty node, not marked as leaf, the Combine loops on it indefinitely. Since this kind of node is empty and has a null bound (min and max are set to zero), testing for the surface area before pushing it to the stack fixes the problem (at least for me, I tried in many test scenes of my render engine and nothing changes in the final output).

I duplicated the minimal example to make it buggy, and I added the fix with a define in tiny_bvh.h.

Hope this helps!

… <= 4, and proposed a simple workaround for now
@jbikker
Copy link
Owner

jbikker commented Mar 3, 2025

Good find. It probably needs a slightly more fundamental fix, but for now, this is a good workaround. Thanks!

@jbikker jbikker merged commit 8de3828 into jbikker:main Mar 3, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants