This commit is contained in:
2026-03-17 09:28:54 -07:00
parent fed0c3afc5
commit f360bb19f5

View File

@@ -40,6 +40,7 @@ impl Bvh{
let len=index-last_index; let len=index-last_index;
let count=len.div_ceil(MAX_SLICE_LEN); let count=len.div_ceil(MAX_SLICE_LEN);
let slice_len=MAX_SLICE_LEN; let slice_len=MAX_SLICE_LEN;
println!("push_slices index={index} len={len} count={count} slice_len={slice_len}");
bvh_nodes.reserve(count); bvh_nodes.reserve(count);
// 0123456789 // 0123456789
// split into groups of MAX_SLICE_LEN=4 // split into groups of MAX_SLICE_LEN=4
@@ -53,6 +54,7 @@ impl Bvh{
let event=&output_events[slice.end]; let event=&output_events[slice.end];
aabb.grow(vec3::try_from_f32_array([event.event.position.x,event.event.position.y,event.event.position.z]).unwrap()); aabb.grow(vec3::try_from_f32_array([event.event.position.x,event.event.position.y,event.event.position.z]).unwrap());
} }
println!("EventSlice slice={slice:?} {}",if inclusive{"inclusive"}else{"exclusive"});
bvh_nodes.push((EventSlice{slice,inclusive},aabb)); bvh_nodes.push((EventSlice{slice,inclusive},aabb));
}; };
// push fixed-size groups // push fixed-size groups
@@ -87,6 +89,7 @@ impl Bvh{
(start_point-p).length_squared() (start_point-p).length_squared()
}).min()?; }).min()?;
let mut prev_event=&output_events[event_slice.slice.start]; let mut prev_event=&output_events[event_slice.slice.start];
let start_time=bot.playback_time(crate::time::from_float(prev_event.time).unwrap());
let mut f=|event:&'a v0::Timed<v0::OutputEvent>|{ let mut f=|event:&'a v0::Timed<v0::OutputEvent>|{
let p0=vec3::try_from_f32_array([prev_event.event.position.x,prev_event.event.position.y,prev_event.event.position.z]).unwrap(); let p0=vec3::try_from_f32_array([prev_event.event.position.x,prev_event.event.position.y,prev_event.event.position.z]).unwrap();
let p1=vec3::try_from_f32_array([event.event.position.x,event.event.position.y,event.event.position.z]).unwrap(); let p1=vec3::try_from_f32_array([event.event.position.x,event.event.position.y,event.event.position.z]).unwrap();
@@ -111,7 +114,10 @@ impl Bvh{
} }
if event_slice.inclusive{ if event_slice.inclusive{
f(&output_events[event_slice.slice.end]); f(&output_events[event_slice.slice.end]);
}else{
} }
let end_time=bot.playback_time(crate::time::from_float(prev_event.time).unwrap());
println!("intersect_leaf {:?} {} start_time={} end_time={}",event_slice.slice,if event_slice.inclusive{"inclusive"}else{"exclusive"},start_time,end_time);
Some(best_distance) Some(best_distance)
}; };
let intersect_aabb=|aabb:&Aabb|{ let intersect_aabb=|aabb:&Aabb|{