mesh: refit host solid-angle BVH from the real root, not node 0#1600
Open
EylonKrause wants to merge 1 commit into
Open
mesh: refit host solid-angle BVH from the real root, not node 0#1600EylonKrause wants to merge 1 commit into
EylonKrause wants to merge 1 commit into
Conversation
bvh_refit_with_solid_angle_host started the recursion at literal node 0, while the sibling bvh_refit_host uses *bvh.root. For a grouped BVH, reorder_top_down_bvh moves leaves to the front and sets *bvh.root > 0, so starting at 0 computed solid_angle_props for a single leaf only and left the root and internal nodes uninitialized. mesh_query_point_sign_winding_number then reads that uninitialized memory, giving wrong winding numbers / NaNs for a grouped CPU mesh built with support_winding_number=True. Start the refit at *bvh.root (no-op for non-grouped builds, where root == 0). Signed-off-by: EylonKrause <eylon1909@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughIn BVH Root Fix
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Author
|
Disclosure: this contribution was authored with an AI coding assistant (Claude) and reviewed before submission. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The host solid-angle BVH refit always starts the recursion at node index
0:whereas the sibling non-solid-angle refit correctly starts at the real root —
bvh_refit_hostdoesbvh_refit_recursive(bvh, *bvh.root)(bvh.cpp). For a grouped BVH (groups != nullptr),build_with_groupsfinishes by callingreorder_top_down_bvh, which moves all leaf nodes to the front and sets*bvh.rootto an index> 0for a non-leaf root. Starting the solid-angle refit at node0(now a leaf) therefore computessolid_angle_propsfor only that single leaf and returns; the root and all other internal nodes keep their uninitializedsolid_angle_props(allocated viawp_alloc_host, not zeroed).mesh_query_point_sign_winding_numbertraverses from*bvh.root, so it reads that garbage → wrong sign / winding-number results (and possible NaNs).This is reachable from Python:
wp.Mesh(..., groups=<array>, support_winding_number=True)on a CPU device passes both straight through towp_mesh_create_hostwith no guard (only the cuBQL constructor rejects the combination). The CUDA path is unaffected —bvh_refit_with_solid_angle_devicedoes a bottom-up refit over the leaf nodes vianode_parentsand never uses a literal root index.Changes
warp/native/mesh.cpp: start the host solid-angle refit at*bvh.root, matchingbvh_refit_host. For a non-grouped host build the root is already0, so that path is unchanged; this only fixes the grouped case.Testing
bvh_refit_with_solid_angle_hostuse the same root as its siblingbvh_refit_host(*bvh.root); the0was incorrect afterreorder_top_down_bvhreassigns the root for grouped builds.support_winding_number=Trueand comparemesh_query_point_sign_winding_numberat known inside/outside points against the non-grouped (or CUDA) result; under ASan it would also surface the uninitializedsolid_angle_propsread.Summary by CodeRabbit