40 for (
int32 i = 0; i < count1; ++i)
48 for (
int32 j = 0; j < count2; ++j)
50 float sij =
b2Dot(n, v2s[j] - v1);
57 if (si > maxSeparation)
64 *edgeIndex = bestIndex;
78 b2Assert(0 <= edge1 && edge1 < poly1->m_count);
86 for (
int32 i = 0; i < count2; ++i)
88 float dot =
b2Dot(normal1, normals2[i]);
98 int32 i2 = i1 + 1 < count2 ? i1 + 1 : 0;
100 c[0].
v =
b2Mul(xf2, vertices2[i1]);
106 c[1].
v =
b2Mul(xf2, vertices2[i2]);
129 if (separationA > totalRadius)
134 if (separationB > totalRadius)
144 if (separationB > separationA + k_tol)
172 int32 iv2 = edge1 + 1 < count1 ? edge1 + 1 : 0;
174 b2Vec2 v11 = vertices1[iv1];
175 b2Vec2 v12 = vertices1[iv2];
177 b2Vec2 localTangent = v12 - v11;
181 b2Vec2 planePoint = 0.5f * (v11 + v12);
186 v11 =
b2Mul(xf1, v11);
187 v12 =
b2Mul(xf1, v12);
190 float frontOffset =
b2Dot(normal, v11);
193 float sideOffset1 = -
b2Dot(tangent, v11) + totalRadius;
194 float sideOffset2 =
b2Dot(tangent, v12) + totalRadius;
219 int32 pointCount = 0;
222 float separation =
b2Dot(normal, clipPoints2[i].v) - frontOffset;
224 if (separation <= totalRadius)
228 cp->
id = clipPoints2[i].
id;
b2Vec2 b2Mul(const b2Mat22 &A, const b2Vec2 &v)
Used for computing contact manifolds.
float b2Dot(const b2Vec2 &a, const b2Vec2 &b)
Perform the dot product on two vectors.
b2Vec2 localNormal
not use for Type::e_points
b2ContactID id
uniquely identifies a contact point between two shapes
#define b2_maxManifoldPoints
static void b2FindIncidentEdge(b2ClipVertex c[2], const b2PolygonShape *poly1, const b2Transform &xf1, int32 edge1, const b2PolygonShape *poly2, const b2Transform &xf2)
doubleAcc dot(const VectorAcc &lhs, const VectorAcc &rhs)
B2_API int32 b2ClipSegmentToLine(b2ClipVertex vOut[2], const b2ClipVertex vIn[2], const b2Vec2 &normal, float offset, int32 vertexIndexA)
Clipping for contact manifolds.
float b2Cross(const b2Vec2 &a, const b2Vec2 &b)
Perform the cross product on two vectors. In 2D this produces a scalar.
b2Vec2 m_vertices[b2_maxPolygonVertices]
int32 pointCount
the number of manifold points
b2Vec2 localPoint
usage depends on manifold type
b2Vec2 localPoint
usage depends on manifold type
b2ManifoldPoint points[b2_maxManifoldPoints]
the points of contact
static float b2FindMaxSeparation(int32 *edgeIndex, const b2PolygonShape *poly1, const b2Transform &xf1, const b2PolygonShape *poly2, const b2Transform &xf2)
b2Vec2 b2MulT(const b2Mat22 &A, const b2Vec2 &v)
float Normalize()
Convert this vector into a unit vector. Returns the length.
void b2CollidePolygons(b2Manifold *manifold, const b2PolygonShape *polyA, const b2Transform &xfA, const b2PolygonShape *polyB, const b2Transform &xfB)
Compute the collision manifold between two polygons.
b2Vec2 m_normals[b2_maxPolygonVertices]