forked from StrafesNET/strafe-project
CrawlResult impls
This commit is contained in:
parent
195014400f
commit
c2f78eab48
@ -12,6 +12,20 @@ pub enum CrawlResult<M:MeshQuery>{
|
|||||||
Miss(FEV<M>),
|
Miss(FEV<M>),
|
||||||
Hit(M::Face,GigaTime),
|
Hit(M::Face,GigaTime),
|
||||||
}
|
}
|
||||||
|
impl<M:MeshQuery> CrawlResult<M>{
|
||||||
|
pub fn hit(self)->Option<(M::Face,GigaTime)>{
|
||||||
|
match self{
|
||||||
|
CrawlResult::Miss(_)=>None,
|
||||||
|
CrawlResult::Hit(face,time)=>Some((face,time)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn miss(self)->Option<FEV<M>>{
|
||||||
|
match self{
|
||||||
|
CrawlResult::Miss(fev)=>Some(fev),
|
||||||
|
CrawlResult::Hit(_,_)=>None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<F:Copy,M:MeshQuery<Normal=Vector3<F>,Offset=Fixed<4,128>>> FEV<M>
|
impl<F:Copy,M:MeshQuery<Normal=Vector3<F>,Offset=Fixed<4,128>>> FEV<M>
|
||||||
where
|
where
|
||||||
|
@ -726,19 +726,13 @@ impl MinkowskiMesh<'_>{
|
|||||||
infinity_body.acceleration=vec3::ZERO;
|
infinity_body.acceleration=vec3::ZERO;
|
||||||
//crawl in from negative infinity along a tangent line to get the closest fev
|
//crawl in from negative infinity along a tangent line to get the closest fev
|
||||||
// TODO: change crawl_fev args to delta time? Optional values?
|
// TODO: change crawl_fev args to delta time? Optional values?
|
||||||
match infinity_fev.crawl(self,&infinity_body,Time::MIN/4,start_time){
|
infinity_fev.crawl(self,&infinity_body,Time::MIN/4,start_time).miss()
|
||||||
crate::face_crawler::CrawlResult::Miss(fev)=>Some(fev),
|
|
||||||
crate::face_crawler::CrawlResult::Hit(_,_)=>None,
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
pub fn predict_collision_in(&self,relative_body:&Body,start_time:Time,time_limit:Time)->Option<(MinkowskiFace,GigaTime)>{
|
pub fn predict_collision_in(&self,relative_body:&Body,start_time:Time,time_limit:Time)->Option<(MinkowskiFace,GigaTime)>{
|
||||||
self.closest_fev_not_inside(relative_body.clone(),start_time).map_or(None,|fev|{
|
self.closest_fev_not_inside(relative_body.clone(),start_time).map_or(None,|fev|{
|
||||||
//continue forwards along the body parabola
|
//continue forwards along the body parabola
|
||||||
match fev.crawl(self,relative_body,start_time,time_limit){
|
fev.crawl(self,relative_body,start_time,time_limit).hit()
|
||||||
crate::face_crawler::CrawlResult::Miss(_)=>None,
|
|
||||||
crate::face_crawler::CrawlResult::Hit(face,time)=>Some((face,time)),
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
pub fn predict_collision_out(&self,relative_body:&Body,start_time:Time,time_limit:Time)->Option<(MinkowskiFace,GigaTime)>{
|
pub fn predict_collision_out(&self,relative_body:&Body,start_time:Time,time_limit:Time)->Option<(MinkowskiFace,GigaTime)>{
|
||||||
@ -746,10 +740,9 @@ impl MinkowskiMesh<'_>{
|
|||||||
let infinity_body=-relative_body.clone();
|
let infinity_body=-relative_body.clone();
|
||||||
self.closest_fev_not_inside(infinity_body,-time_limit).map_or(None,|fev|{
|
self.closest_fev_not_inside(infinity_body,-time_limit).map_or(None,|fev|{
|
||||||
//continue backwards along the body parabola
|
//continue backwards along the body parabola
|
||||||
match fev.crawl(self,&infinity_body,-time_limit,-start_time){
|
fev.crawl(self,&infinity_body,-time_limit,-start_time).hit()
|
||||||
crate::face_crawler::CrawlResult::Miss(_)=>None,
|
//no need to test -time<time_limit because of the first step
|
||||||
crate::face_crawler::CrawlResult::Hit(face,time)=>Some((face,-time)),//no need to test -time<time_limit because of the first step
|
.map(|(face,time)|(face,-time))
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
pub fn predict_collision_face_out(&self,relative_body:&Body,start_time:Time,time_limit:Time,contact_face_id:MinkowskiFace)->Option<(MinkowskiEdge,GigaTime)>{
|
pub fn predict_collision_face_out(&self,relative_body:&Body,start_time:Time,time_limit:Time,contact_face_id:MinkowskiFace)->Option<(MinkowskiEdge,GigaTime)>{
|
||||||
@ -785,10 +778,7 @@ impl MinkowskiMesh<'_>{
|
|||||||
}
|
}
|
||||||
fn infinity_in(&self,infinity_body:Body)->Option<(MinkowskiFace,GigaTime)>{
|
fn infinity_in(&self,infinity_body:Body)->Option<(MinkowskiFace,GigaTime)>{
|
||||||
let infinity_fev=self.infinity_fev(-infinity_body.velocity,infinity_body.position);
|
let infinity_fev=self.infinity_fev(-infinity_body.velocity,infinity_body.position);
|
||||||
match infinity_fev.crawl(self,&infinity_body,Time::MIN/4,infinity_body.time){
|
infinity_fev.crawl(self,&infinity_body,Time::MIN/4,infinity_body.time).hit()
|
||||||
crate::face_crawler::CrawlResult::Miss(_)=>None,
|
|
||||||
crate::face_crawler::CrawlResult::Hit(face,time)=>Some((face,time)),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pub fn is_point_in_mesh(&self,point:Planar64Vec3)->bool{
|
pub fn is_point_in_mesh(&self,point:Planar64Vec3)->bool{
|
||||||
let infinity_body=Body::new(point,vec3::Y,vec3::ZERO,Time::ZERO);
|
let infinity_body=Body::new(point,vec3::Y,vec3::ZERO,Time::ZERO);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user