(c []B2ClipVertex, poly1 *B2PolygonShape, xf1 B2Transform, edge1 int, poly2 *B2PolygonShape, xf2 B2Transform)
| 37 | } |
| 38 | |
| 39 | func B2FindIncidentEdge(c []B2ClipVertex, poly1 *B2PolygonShape, xf1 B2Transform, edge1 int, poly2 *B2PolygonShape, xf2 B2Transform) { |
| 40 | |
| 41 | normals1 := poly1.M_normals |
| 42 | |
| 43 | count2 := poly2.M_count |
| 44 | vertices2 := poly2.M_vertices |
| 45 | normals2 := poly2.M_normals |
| 46 | |
| 47 | B2Assert(0 <= edge1 && edge1 < poly1.M_count) |
| 48 | |
| 49 | // Get the normal of the reference edge in poly2's frame. |
| 50 | normal1 := B2RotVec2MulT(xf2.Q, B2RotVec2Mul(xf1.Q, normals1[edge1])) |
| 51 | |
| 52 | // Find the incident edge on poly2. |
| 53 | index := 0 |
| 54 | minDot := B2_maxFloat |
| 55 | for i := 0; i < count2; i++ { |
| 56 | dot := B2Vec2Dot(normal1, normals2[i]) |
| 57 | if dot < minDot { |
| 58 | minDot = dot |
| 59 | index = i |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | // Build the clip vertices for the incident edge. |
| 64 | i1 := index |
| 65 | i2 := 0 |
| 66 | if i1+1 < count2 { |
| 67 | i2 = i1 + 1 |
| 68 | } |
| 69 | |
| 70 | c[0].V = B2TransformVec2Mul(xf2, vertices2[i1]) |
| 71 | c[0].Id.IndexA = uint8(edge1) |
| 72 | c[0].Id.IndexB = uint8(i1) |
| 73 | c[0].Id.TypeA = B2ContactFeature_Type.E_face |
| 74 | c[0].Id.TypeB = B2ContactFeature_Type.E_vertex |
| 75 | |
| 76 | c[1].V = B2TransformVec2Mul(xf2, vertices2[i2]) |
| 77 | c[1].Id.IndexA = uint8(edge1) |
| 78 | c[1].Id.IndexB = uint8(i2) |
| 79 | c[1].Id.TypeA = B2ContactFeature_Type.E_face |
| 80 | c[1].Id.TypeB = B2ContactFeature_Type.E_vertex |
| 81 | } |
| 82 | |
| 83 | // Find edge normal of max separation on A - return if separating axis is found |
| 84 | // Find edge normal of max separation on B - return if separation axis is found |
no test coverage detected