fix time inversion

This commit is contained in:
Quaternions 2023-11-16 19:18:07 -08:00
parent 46c6271286
commit d191538aa8
2 changed files with 8 additions and 8 deletions

View File

@ -101,8 +101,8 @@ enum Transition<F,E:DirectedEdge,V>{
} }
best_transtition best_transtition
} }
pub fn crawl_fev<F:Copy,E:Copy+DirectedEdge,V:Copy>(mut fev:FEV<F,E,V>,mesh:&impl MeshQuery<F,E,V>,relative_body:&Body,time_limit:Time)->Option<(F,Time)>{ pub fn crawl_fev<F:Copy,E:Copy+DirectedEdge,V:Copy>(mut fev:FEV<F,E,V>,mesh:&impl MeshQuery<F,E,V>,relative_body:&Body,start_time:Time,time_limit:Time)->Option<(F,Time)>{
let mut time=relative_body.time; let mut time=start_time;
loop{ loop{
match next_transition(&fev,time,mesh,relative_body,time_limit){ match next_transition(&fev,time,mesh,relative_body,time_limit){
Transition::Miss=>return None, Transition::Miss=>return None,
@ -115,10 +115,10 @@ pub enum CrawlResult<F,E:DirectedEdge,V>{
Closest(FEV<F,E,V>), Closest(FEV<F,E,V>),
Hit(F,Time), Hit(F,Time),
} }
pub fn crawl_fev_from_negative_infinity<F:Copy,E:Copy+DirectedEdge,V:Copy>(mut fev:FEV<F,E,V>,mesh:&impl MeshQuery<F,E,V>,relative_body:&Body)->CrawlResult<F,E,V>{ pub fn crawl_fev_from_negative_infinity<F:Copy,E:Copy+DirectedEdge,V:Copy>(mut fev:FEV<F,E,V>,mesh:&impl MeshQuery<F,E,V>,relative_body:&Body,time_limit:Time)->CrawlResult<F,E,V>{
let mut time=Time::MIN; let mut time=Time::MIN;
loop{ loop{
match next_transition(&fev,time,mesh,relative_body,relative_body.time){ match next_transition(&fev,time,mesh,relative_body,time_limit){
Transition::Miss=>return CrawlResult::Closest(fev), Transition::Miss=>return CrawlResult::Closest(fev),
Transition::Next(next_fev,next_time)=>(fev,time)=(next_fev,next_time), Transition::Next(next_fev,next_time)=>(fev,time)=(next_fev,next_time),
Transition::Hit(face,time)=>return CrawlResult::Hit(face,time),//algorithm breaks down inside without full fat voronoi Transition::Hit(face,time)=>return CrawlResult::Hit(face,time),//algorithm breaks down inside without full fat voronoi

View File

@ -355,18 +355,18 @@ impl MinkowskiMesh<'_>{
} }
pub fn predict_collision_in(&self,relative_body:&crate::physics::Body,time_limit:crate::integer::Time)->Option<(MinkowskiFace,crate::integer::Time)>{ pub fn predict_collision_in(&self,relative_body:&crate::physics::Body,time_limit:crate::integer::Time)->Option<(MinkowskiFace,crate::integer::Time)>{
let start_vert=FEV::<MinkowskiFace,MinkowskiDirectedEdge,MinkowskiVert>::Vert(self.farthest_vert((-relative_body.clone()).infinity_dir())); let start_vert=FEV::<MinkowskiFace,MinkowskiDirectedEdge,MinkowskiVert>::Vert(self.farthest_vert((-relative_body.clone()).infinity_dir()));
match crate::face_crawler::crawl_fev_from_negative_infinity(start_vert,self,relative_body){ match crate::face_crawler::crawl_fev_from_negative_infinity(start_vert,self,relative_body,relative_body.time){
crate::face_crawler::CrawlResult::Closest(fev)=>{ crate::face_crawler::CrawlResult::Closest(fev)=>{
crate::face_crawler::crawl_fev(fev,self,relative_body,time_limit) crate::face_crawler::crawl_fev(fev,self,relative_body,relative_body.time,time_limit)
}, },
crate::face_crawler::CrawlResult::Hit(_,_)=>None,//already in or passed crate::face_crawler::CrawlResult::Hit(_,_)=>None,//already in or passed
} }
} }
pub fn predict_collision_out(&self,relative_body:&crate::physics::Body,time_limit:crate::integer::Time)->Option<(MinkowskiFace,crate::integer::Time)>{ pub fn predict_collision_out(&self,relative_body:&crate::physics::Body,time_limit:crate::integer::Time)->Option<(MinkowskiFace,crate::integer::Time)>{
let start_vert=FEV::<MinkowskiFace,MinkowskiDirectedEdge,MinkowskiVert>::Vert(self.farthest_vert(relative_body.infinity_dir())); let start_vert=FEV::<MinkowskiFace,MinkowskiDirectedEdge,MinkowskiVert>::Vert(self.farthest_vert(relative_body.infinity_dir()));
match crate::face_crawler::crawl_fev_from_negative_infinity(start_vert,self,&-relative_body.clone()){ match crate::face_crawler::crawl_fev_from_negative_infinity(start_vert,self,&-relative_body.clone(),-time_limit){
crate::face_crawler::CrawlResult::Closest(fev)=>{ crate::face_crawler::CrawlResult::Closest(fev)=>{
crate::face_crawler::crawl_fev(fev,self,&-relative_body.clone(),-time_limit).map(|t|(t.0,-t.1)) crate::face_crawler::crawl_fev(fev,self,&-relative_body.clone(),-time_limit,-relative_body.time).map(|t|(t.0,-t.1))
}, },
crate::face_crawler::CrawlResult::Hit(face,time)=>Some((face,-time)), crate::face_crawler::CrawlResult::Hit(face,time)=>Some((face,-time)),
} }