27 #define USE_PERSISTENT_CONTACTS 1
92 #define b2Dot(a,b) (a).dot(b)
93 #define b2Mul(a,b) (a)*(b)
94 #define b2MulT(a,b) (a).transpose()*(b)
95 #define b2Cross(a,b) (a).cross(b)
96 #define btCrossS(a,s) btVector3(s * a.getY(), -s * a.getX(),0.f)
111 if (distance0 <= 0.0f) vOut[numOut++] = vIn[0];
112 if (distance1 <= 0.0f) vOut[numOut++] = vIn[1];
115 if (distance0 * distance1 < 0.0f)
118 btScalar interp = distance0 / (distance0 - distance1);
119 vOut[numOut].
v = vIn[0].
v + interp * (vIn[1].
v - vIn[0].
v);
120 if (distance0 > 0.0f)
122 vOut[numOut].
id = vIn[0].
id;
126 vOut[numOut].
id = vIn[1].
id;
144 btAssert(0 <= edge1 && edge1 < poly1->getVertexCount());
155 index = (int) normal1.minDot( vertices2, count2, minDot);
179 edge = (int) dLocal1.maxDot( normals1, count1, maxDot);
189 int prevEdge = edge - 1 >= 0 ? edge - 1 : count1 - 1;
197 int nextEdge = edge + 1 < count1 ? edge + 1 : 0;
208 if (sPrev > s && sPrev > sNext)
212 bestSeparation = sPrev;
218 bestSeparation = sNext;
230 edge = bestEdge - 1 >= 0 ? bestEdge - 1 : count1 - 1;
232 edge = bestEdge + 1 < count1 ? bestEdge + 1 : 0;
240 if (s > bestSeparation)
251 *edgeIndex = bestEdge;
252 return bestSeparation;
265 btAssert(0 <= edge1 && edge1 < poly1->getVertexCount());
273 for (
int i = 0; i < count2; ++i)
285 int i2 = i1 + 1 < count2 ? i1 + 1 : 0;
287 c[0].
v =
b2Mul(xf2, vertices2[i1]);
292 c[1].
v =
b2Mul(xf2, vertices2[i2]);
312 if (separationA > 0.0f)
317 if (separationB > 0.0f)
325 const btScalar k_relativeTol = 0.98f;
326 const btScalar k_absoluteTol = 0.001f;
329 if (separationB > k_relativeTol * separationA + k_absoluteTol)
355 btVector3 v12 = edge1 + 1 < count1 ? vertices1[edge1+1] : vertices1[0];
363 v11 =
b2Mul(xf1, v11);
364 v12 =
b2Mul(xf1, v12);
397 btVector3 manifoldNormal = flip ? -frontNormal : frontNormal;
402 btScalar separation =
b2Dot(frontNormal, clipPoints2[i].v) - frontOffset;
404 if (separation <= 0.0f)
412 manifold->
addContactPoint(-manifoldNormal,clipPoints2[i].v,separation);