27 #define USE_PERSISTENT_CONTACTS 1
86 #define b2Dot(a, b) (a).dot(b)
87 #define b2Mul(a, b) (a) * (b)
88 #define b2MulT(a, b) (a).transpose() * (b)
89 #define b2Cross(a, b) (a).cross(b)
90 #define btCrossS(a, s) btVector3(s* a.getY(), -s* a.getX(), 0.f)
105 if (distance0 <= 0.0f) vOut[numOut++] = vIn[0];
106 if (distance1 <= 0.0f) vOut[numOut++] = vIn[1];
109 if (distance0 * distance1 < 0.0f)
112 btScalar interp = distance0 / (distance0 - distance1);
113 vOut[numOut].
v = vIn[0].
v + interp * (vIn[1].
v - vIn[0].
v);
114 if (distance0 > 0.0f)
116 vOut[numOut].
id = vIn[0].
id;
120 vOut[numOut].
id = vIn[1].
id;
138 btAssert(0 <= edge1 && edge1 < poly1->getVertexCount());
149 index = (int)normal1.minDot(vertices2, count2, minDot);
173 edge = (int)dLocal1.maxDot(normals1, count1, maxDot);
183 int prevEdge = edge - 1 >= 0 ? edge - 1 : count1 - 1;
191 int nextEdge = edge + 1 < count1 ? edge + 1 : 0;
202 if (sPrev > s && sPrev > sNext)
206 bestSeparation = sPrev;
212 bestSeparation = sNext;
224 edge = bestEdge - 1 >= 0 ? bestEdge - 1 : count1 - 1;
226 edge = bestEdge + 1 < count1 ? bestEdge + 1 : 0;
234 if (s > bestSeparation)
245 *edgeIndex = bestEdge;
246 return bestSeparation;
259 btAssert(0 <= edge1 && edge1 < poly1->getVertexCount());
267 for (
int i = 0; i < count2; ++i)
279 int i2 = i1 + 1 < count2 ? i1 + 1 : 0;
281 c[0].
v =
b2Mul(xf2, vertices2[i1]);
286 c[1].
v =
b2Mul(xf2, vertices2[i2]);
305 if (separationA > 0.0f)
310 if (separationB > 0.0f)
318 const btScalar k_relativeTol = 0.98f;
319 const btScalar k_absoluteTol = 0.001f;
322 if (separationB > k_relativeTol * separationA + k_absoluteTol)
348 btVector3 v12 = edge1 + 1 < count1 ? vertices1[edge1 + 1] : vertices1[0];
355 v11 =
b2Mul(xf1, v11);
356 v12 =
b2Mul(xf1, v12);
388 btVector3 manifoldNormal = flip ? -frontNormal : frontNormal;
393 btScalar separation =
b2Dot(frontNormal, clipPoints2[i].v) - frontOffset;
395 if (separation <= 0.0f)
402 manifold->
addContactPoint(-manifoldNormal, clipPoints2[i].v, separation);