diff --git a/engine/physics/src/physics.rs b/engine/physics/src/physics.rs index 65479c0..22f7a26 100644 --- a/engine/physics/src/physics.rs +++ b/engine/physics/src/physics.rs @@ -796,13 +796,12 @@ impl TouchingState{ let minkowski=model_physics::MinkowskiMesh::minkowski_sum(model_mesh,hitbox_mesh.transformed_mesh()); collector.collect(minkowski.predict_collision_face_out(&relative_body,start_time..collector.time(),contact.face_id).map(|(out_edge,time)|{ // TODO: determine if this code should go inside predict_collision_face_out - // check if the face across the out_edge is flush to contact.face_id - let (src_face_n,_src_face_d)=minkowski.face_nd(contact.face_id); // the face across may be left or right depending on the directed edge parity - let dst_face=minkowski.edge_faces(out_edge.as_undirected()).as_ref()[out_edge.parity() as usize]; - let (dst_face_n,_dst_face_d)=minkowski.face_nd(dst_face); + let &[f0,f1]=minkowski.edge_faces(out_edge.as_undirected()).as_ref(); + let (f0n,_f0d)=minkowski.face_nd(f0); + let (f1n,_f1d)=minkowski.face_nd(f1); // are they exactly flush - if src_face_n.cross(dst_face_n)==vec3::ZERO_6 + if f0n.cross(f1n)==vec3::ZERO_6 // implicitly don't need to check d values because faces share two vertices // && n0*d1==n1*d0 { @@ -810,7 +809,7 @@ impl TouchingState{ time:relative_body.time+time.into(), instruction:InternalInstruction::CollisionTransfer( *contact, - dst_face, + if out_edge.parity(){f1}else{f0}, ), } }else{