From b5449fc0d816c180bfd75014cd7e364366691047 Mon Sep 17 00:00:00 2001 From: Daniel Oom Date: Sun, 7 Jul 2024 17:11:42 +0200 Subject: [PATCH] Use unsafe geometry indexing --- kdtree/src/lib.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/kdtree/src/lib.rs b/kdtree/src/lib.rs index 82b83c60..076e5aab 100644 --- a/kdtree/src/lib.rs +++ b/kdtree/src/lib.rs @@ -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)) }