diff --git a/src/model_physics.rs b/src/model_physics.rs index ec7364b..9646e00 100644 --- a/src/model_physics.rs +++ b/src/model_physics.rs @@ -52,6 +52,46 @@ pub trait MeshQuery{ impl MeshQuery for PhysicsMesh{ fn closest_fev(&self,point:Planar64Vec3)->FEV{ //put some genius code right here + + //TODO write genius code + //brute force + let mut best_distance_squared=Planar64::MAX; + let mut best_fev:FEV; + //check each vert + for (i,v) in self.verts.iter().enumerate(){ + let d=(v.0-point).dot(v.0-point); + if d::Vert(VertId(i)); + } + } + let face_dots=self.faces.iter().map(|f|f.normal.dot(point)); + //check each edge + for (i,v) in self.edge_topology.iter().enumerate(){ + let verts=self.edge_verts(EdgeId(i)); + if verts.iter().all(|&(vert_id,face_id)|{ + let (n,d)=self.face_nd(face_id); + n.dot(point)::Edge(EdgeId(i)); + } + } + //check each face todo!() } fn face_nd(&self,face_id:FaceId)->(Planar64Vec3,Planar64){