Skip to content

Commit

Permalink
fix(bvh): fix bvh raycast returning incorrect primitive index
Browse files Browse the repository at this point in the history
  • Loading branch information
Silverlan committed Feb 20, 2024
1 parent f6a8f08 commit e9e9624
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions core/shared/src/entities/components/bvh_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ bool pragma::bvh::MeshBvhTree::Raycast(const Vector3 &origin, const Vector3 &dir
auto ray = get_ray(origin, dir, minDist, maxDist);
bvh.intersect<false, use_robust_traversal>(ray, bvh.get_root().index, stack, [&](size_t begin, size_t end) {
for(size_t i = begin; i < end; ++i) {
size_t j = should_permute ? i : bvh.prim_ids[i];
if(auto hit = precomputed_tris[j].intersect(ray)) {
prim_id = i;
size_t j = bvh.prim_ids[i];
if(auto hit = precomputed_tris[i].intersect(ray)) {
prim_id = j;
std::tie(u, v) = *hit;
}
}
Expand Down

0 comments on commit e9e9624

Please sign in to comment.