brute force t for plain mesh
This commit is contained in:
parent
b897d4a662
commit
6aa0e790d8
@ -171,6 +171,28 @@ impl PhysicsMesh{
|
||||
pub fn verts<'a>(&'a self)->impl Iterator<Item=Planar64Vec3>+'a{
|
||||
self.verts.iter().map(|Vert(pos)|*pos)
|
||||
}
|
||||
pub fn brute_t(&self,body:&crate::physics::Body,time_limit:crate::integer::Time)->Option<(FaceId,crate::integer::Time)>{
|
||||
//check each face
|
||||
let mut best_time=time_limit;
|
||||
let mut best_face=None;
|
||||
for (i,f) in self.face_topology.iter().enumerate(){
|
||||
let (n,d)=self.face_nd(FaceId(i));
|
||||
for t in crate::zeroes::zeroes2((n.dot(body.position)-d)*2,n.dot(body.velocity)*2,n.dot(body.acceleration)){
|
||||
let t=body.time+crate::integer::Time::from(t);
|
||||
if body.time<t&&t<best_time&&n.dot(body.extrapolated_velocity(t))<Planar64::ZERO{
|
||||
let p=body.extrapolated_position(t);
|
||||
if f.edges.iter().all(|&(_,face_id)|{
|
||||
let (n,d)=self.face_nd(face_id);
|
||||
n.dot(p)<=d
|
||||
}){
|
||||
best_time=t;
|
||||
best_face=Some(FaceId(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
best_face.map(|f|(f,best_time))
|
||||
}
|
||||
}
|
||||
impl MeshQuery<FaceId,EdgeId,VertId> for PhysicsMesh{
|
||||
fn closest_fev(&self,point:Planar64Vec3)->FEV<FaceId,EdgeId,VertId>{
|
||||
|
Loading…
Reference in New Issue
Block a user