forked from StrafesNET/strafe-client
fix not moving
This commit is contained in:
parent
d191538aa8
commit
8839b8fbb3
@ -354,22 +354,26 @@ impl MinkowskiMesh<'_>{
|
||||
MinkowskiVert::VertVert(self.mesh0.farthest_vert(dir),self.mesh1.farthest_vert(-dir))
|
||||
}
|
||||
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()));
|
||||
(-relative_body.clone()).infinity_dir().map_or(None,|dir|{
|
||||
let start_vert=FEV::<MinkowskiFace,MinkowskiDirectedEdge,MinkowskiVert>::Vert(self.farthest_vert(dir));
|
||||
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::crawl_fev(fev,self,relative_body,relative_body.time,time_limit)
|
||||
},
|
||||
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)>{
|
||||
let start_vert=FEV::<MinkowskiFace,MinkowskiDirectedEdge,MinkowskiVert>::Vert(self.farthest_vert(relative_body.infinity_dir()));
|
||||
relative_body.infinity_dir().map_or(None,|dir|{
|
||||
let start_vert=FEV::<MinkowskiFace,MinkowskiDirectedEdge,MinkowskiVert>::Vert(self.farthest_vert(dir));
|
||||
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::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)),
|
||||
}
|
||||
})
|
||||
}
|
||||
pub fn predict_collision_face_out(&self,relative_body:&crate::physics::Body,time_limit:crate::integer::Time,contact_face_id:MinkowskiFace)->Option<(MinkowskiEdge,crate::integer::Time)>{
|
||||
//no algorithm needed, there is only one state and two cases (Edge,None)
|
||||
|
@ -968,11 +968,15 @@ impl Body{
|
||||
self.velocity=self.extrapolated_velocity(time);
|
||||
self.time=time;
|
||||
}
|
||||
pub fn infinity_dir(&self)->Planar64Vec3{
|
||||
pub fn infinity_dir(&self)->Option<Planar64Vec3>{
|
||||
if self.acceleration==Planar64Vec3::ZERO{
|
||||
self.velocity
|
||||
if self.velocity==Planar64Vec3::ZERO{
|
||||
None
|
||||
}else{
|
||||
self.acceleration
|
||||
Some(self.velocity)
|
||||
}
|
||||
}else{
|
||||
Some(self.acceleration)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user