Skip to content

Commit

Permalink
Use unsafe geometry indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Oom committed Jul 7, 2024
1 parent 1ad88be commit b5449fc
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions kdtree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@ fn intersect_closest(
.iter()
.filter_map(|index| {
let index = *index;
geometries[index as usize]
.intersect_ray(ray)
.and_then(|intersection| {
t_range
.contains(&intersection.t)
.then_some((index, intersection))
})
let geometry = unsafe { geometries.get_unchecked(index as usize) };
geometry.intersect_ray(ray).and_then(|intersection| {
t_range
.contains(&intersection.t)
.then_some((index, intersection))
})
})
.min_by(|a, b| f32::total_cmp(&a.1.t, &b.1.t))
}
Expand Down

0 comments on commit b5449fc

Please sign in to comment.