forked from StrafesNET/roblox-bot-player
tweaks
This commit is contained in:
@@ -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<PhysicsTime>{
|
||||
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|{
|
||||
|
||||
Reference in New Issue
Block a user