From 7595464050321e0992cdec65e0c0e6708d5f2693 Mon Sep 17 00:00:00 2001 From: Rhys Lloyd Date: Fri, 13 Mar 2026 10:37:39 -0700 Subject: [PATCH] tweaks --- lib/src/bvh.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/src/bvh.rs b/lib/src/bvh.rs index 2fd0bbe..2e5df08 100644 --- a/lib/src/bvh.rs +++ b/lib/src/bvh.rs @@ -35,7 +35,7 @@ impl Bvh{ let mut push_slices=|index:usize|{ let len=index-last_index; let count=len.div_ceil(MAX_SLICE_LEN); - let node_len=len/count; + let slice_len=len/count; bvh_nodes.reserve(count); // 0123456789 // last_index=0 @@ -55,10 +55,10 @@ impl Bvh{ }; // push fixed-size groups for i in 0..count-1{ - push_slice((last_index+i*node_len)..(last_index+(i+1)*node_len)); + push_slice((last_index+i*slice_len)..(last_index+(i+1)*slice_len)); } // push last group which may be shorter - push_slice((last_index+(count-1)*node_len)..index); + push_slice((last_index+(count-1)*slice_len)..index); last_index=index; }; // find discontinuities (teleports) and avoid forming a nvh node across them @@ -75,6 +75,7 @@ impl Bvh{ pub fn closest_time_to_point(&self,bot:&CompleteBot,point:glam::Vec3)->Option{ let start_point=vec3::try_from_f32_array(point.to_array()).unwrap(); let output_events=&bot.timelines().output_events; + // grow a sphere starting at start_point until we find the closest point on the bot output events let intersect_leaf=|leaf:&EventSlice|{ // calculate the distance to the leaf contents output_events[leaf.0.start..leaf.0.end].iter().map(|event|{