45 float offset =
b2Dot(n, Q - A);
48 if (oneSided && offset < 0.0
f)
54 float u =
b2Dot(e, B - Q);
55 float v =
b2Dot(e, Q - A);
68 float dd =
b2Dot(d, d);
69 if (dd > radius * radius)
80 float u1 =
b2Dot(e1, B1 - Q);
106 float dd =
b2Dot(d, d);
107 if (dd > radius * radius)
118 float v2 =
b2Dot(e2, Q - A2);
140 float den =
b2Dot(e, e);
142 b2Vec2 P = (1.0f / den) * (u * A + v * B);
144 float dd =
b2Dot(d, d);
145 if (dd > radius * radius)
213 b2Vec2 axes[2] = { normal1, -normal1 };
216 for (
int32 j = 0; j < 2; ++j)
287 float offset1 =
b2Dot(normal1, centroidB - v1);
290 if (oneSided && offset1 < 0.0
f)
319 const float k_relativeTol = 0.98f;
320 const float k_absoluteTol = 0.001f;
323 if (polygonAxis.
separation - radius > k_relativeTol * (edgeAxis.
separation - radius) + k_absoluteTol)
325 primaryAxis = polygonAxis;
329 primaryAxis = edgeAxis;
340 bool convex1 =
b2Cross(edge0, edge1) >= 0.0f;
345 bool convex2 =
b2Cross(edge1, edge2) >= 0.0f;
347 const float sinTol = 0.1f;
348 bool side1 =
b2Dot(primaryAxis.
normal, edge1) <= 0.0f;
366 primaryAxis = edgeAxis;
384 primaryAxis = edgeAxis;
398 for (
int32 i = 1; i < tempPolygonB.
count; ++i)
401 if (value < bestValue)
408 int32 i1 = bestIndex;
409 int32 i2 = i1 + 1 < tempPolygonB.
count ? i1 + 1 : 0;
411 clipPoints[0].
v = tempPolygonB.
vertices[i1];
417 clipPoints[1].
v = tempPolygonB.
vertices[i2];
435 clipPoints[0].
v = v2;
441 clipPoints[1].
v = v1;
448 ref.
i2 = ref.
i1 + 1 < tempPolygonB.
count ? ref.
i1 + 1 : 0;
494 int32 pointCount = 0;
501 if (separation <= radius)
508 cp->
id = clipPoints2[i].
id;
void b2CollideEdgeAndPolygon(b2Manifold *manifold, const b2EdgeShape *edgeA, const b2Transform &xfA, const b2PolygonShape *polygonB, const b2Transform &xfB)
Compute the collision manifold between an edge and a polygon.
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
static b2EPAxis b2ComputeEdgeSeparation(const b2TempPolygon &polygonB, const b2Vec2 &v1, const b2Vec2 &normal1)
b2ContactID id
uniquely identifies a contact point between two shapes
#define b2_maxManifoldPoints
b2Vec2 m_vertex0
Optional adjacent vertices. These are used for smooth collision.
b2Vec2 normals[b2_maxPolygonVertices]
void SetZero()
Set this vector to all zeros.
B2_API int32 b2ClipSegmentToLine(b2ClipVertex vOut[2], const b2ClipVertex vIn[2], const b2Vec2 &normal, float offset, int32 vertexIndexA)
Clipping for contact manifolds.
void Set(float x_, float y_)
Set this vector to some specified coordinates.
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 vertices[b2_maxPolygonVertices]
b2Vec2 localPoint
usage depends on manifold type
b2Vec2 localPoint
usage depends on manifold type
b2ManifoldPoint points[b2_maxManifoldPoints]
the points of contact
b2Vec2 b2MulT(const b2Mat22 &A, const b2Vec2 &v)
b2Vec2 m_vertex1
These are the edge vertices.
float Normalize()
Convert this vector into a unit vector. Returns the length.
#define b2_maxPolygonVertices
bool m_oneSided
Uses m_vertex0 and m_vertex3 to create smooth collision.
b2Vec2 m_normals[b2_maxPolygonVertices]
static b2EPAxis b2ComputePolygonSeparation(const b2TempPolygon &polygonB, const b2Vec2 &v1, const b2Vec2 &v2)
void b2CollideEdgeAndCircle(b2Manifold *manifold, const b2EdgeShape *edgeA, const b2Transform &xfA, const b2CircleShape *circleB, const b2Transform &xfB)
Compute the collision manifold between an edge and a circle.