diff --git a/src/model_physics.rs b/src/model_physics.rs index 9d9a7a7..d6d0f09 100644 --- a/src/model_physics.rs +++ b/src/model_physics.rs @@ -229,6 +229,13 @@ impl PhysicsMesh{ } best_face.map(|f|(f,best_time)) } + fn vert_directed_edges(&self,vert_id:VertId)->Cow>{ + Cow::Borrowed(&self.vert_topology[vert_id.0].edges) + } + fn directed_edge_n(&self,directed_edge_id:DirectedEdgeId)->Planar64Vec3{ + let verts=self.edge_verts(directed_edge_id.as_edge_id()); + (self.vert(verts[1].clone())-self.vert(verts[0].clone()))*(directed_edge_id.signum() as i64) + } } impl MeshQuery for PhysicsMesh{ fn closest_fev(&self,point:Planar64Vec3)->FEV{ @@ -290,7 +297,8 @@ impl MeshQuery for PhysicsMesh{ Cow::Borrowed(&self.edge_topology[edge_id.0].verts) } fn vert_edges(&self,vert_id:VertId)->Cow>{ - Cow::Borrowed(&self.vert_topology[vert_id.0].edges) + //not poggers + Cow::Owned(self.vert_topology[vert_id.0].edges.iter().map(|directed_edge_id|directed_edge_id.as_edge_id()).collect()) } fn vert_faces(&self,vert_id:VertId)->Cow>{ Cow::Borrowed(&self.vert_topology[vert_id.0].faces) @@ -376,6 +384,14 @@ impl TransformedMesh<'_>{ } best_face.map(|f|(f,best_time)) } + #[inline] + fn vert_directed_edges(&self,vert_id:VertId)->Cow>{ + self.mesh.vert_directed_edges(vert_id) + } + #[inline] + fn directed_edge_n(&self,directed_edge_id:DirectedEdgeId)->Planar64Vec3{ + self.mesh.directed_edge_n(directed_edge_id) + } } impl MeshQuery for TransformedMesh<'_>{ fn closest_fev(&self,point:Planar64Vec3)->FEV{ @@ -588,13 +604,24 @@ impl MeshQuery for MinkowskiMesh<'_>{ fn vert_edges(&self,vert_id:MinkowskiVert)->Cow>{ match vert_id{ MinkowskiVert::VertVert(v0,v1)=>{ - let v0e=self.mesh0.vert_edges(v0); - let v1e=self.mesh1.vert_edges(v1); - //uh oh dot product - //pass all dots? - //it's a convex hull of {v0e,-v1e} - //each edge needs to know which vert to use from the other mesh - todo!() + let mut edges=Vec::new(); + let v0e=self.mesh0.vert_directed_edges(v0); + let v1f=self.mesh1.vert_faces(v1); + for &directed_edge_id in v0e.iter(){ + let n=self.mesh0.directed_edge_n(directed_edge_id); + if v1f.iter().all(|&face_id|n.dot(self.mesh1.face_nd(face_id).0)