diff --git a/src/model_physics.rs b/src/model_physics.rs index 19731fc..112f521 100644 --- a/src/model_physics.rs +++ b/src/model_physics.rs @@ -169,12 +169,13 @@ pub trait MeshQuery{ } impl MeshQuery for PhysicsMesh{ fn closest_fev(&self,point:Planar64Vec3)->FEV{ - //put some genius code right here + //TODO: put some genius code right here - //TODO write genius code - //brute force + //brute force for now let mut best_distance_squared=Planar64::MAX; - let mut best_fev:FEV; + //make something up as default ret + //hopefully empty meshes don't make their way through here + let mut best_fev=FEV::::Vert(VertId(0)); //check each vert for (i,v) in self.verts.iter().enumerate(){ let d=(v.0-point).dot(v.0-point); @@ -183,34 +184,31 @@ impl MeshQuery for PhysicsMesh{ best_fev=FEV::::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)); + for (i,e) in self.edge_topology.iter().enumerate(){ + let v0=self.vert(e.verts[0]); + let v1=self.vert(e.verts[1]); + let n=v1-v0; + //n.cross(point-v0)=sin(t)*n*dis + let d=n.dot(point-v0); + if d::Edge(EdgeId(i)); + } } } + let face_dots:Vec=self.faces.iter().map(|f|f.normal.dot(point)).collect(); //check each face - todo!() + for (i,f) in self.face_topology.iter().enumerate(){ + if face_dots[i]::Face(FaceId(i)); + } + } + best_fev } fn face_nd(&self,face_id:FaceId)->(Planar64Vec3,Planar64){ (self.faces[face_id.0].normal,self.faces[face_id.0].dot)