convexConvex method
bool
convexConvex(
- ConvexPolyhedron si,
- ConvexPolyhedron sj,
- Vec3 xi,
- Vec3 xj,
- Quaternion qi,
- Quaternion qj,
- Body bi,
- Body bj, [
- Shape? rsi,
- Shape? rsj,
- bool justTest = false,
- List<
int> ? faceListA, - List<
int> ? faceListB,
Implementation
bool convexConvex(
ConvexPolyhedron si,
ConvexPolyhedron sj,
Vec3 xi,
Vec3 xj,
Quaternion qi,
Quaternion qj,
Body bi,
Body bj,
[
Shape? rsi,
Shape? rsj,
bool justTest = false,
List<int>? faceListA,
List<int>? faceListB
]){
final sepAxis = _convexConvexSepAxis;
if (xi.distanceTo(xj) > si.boundingSphereRadius + sj.boundingSphereRadius) {
return false;
}
if (si.findSeparatingAxis(sj, xi, qi, xj, qj, sepAxis, faceListA, faceListB)) {
final List<ConvexPolyhedronContactPoint> res = [];
final q = _convexConvexQ;
si.clipAgainstHull(xi, qi, sj, xj, qj, sepAxis, -100, 100, res);
int numContacts = 0;
for (int j = 0; j != res.length; j++) {
if (justTest) {
return true;
}
final r = createContactEquation(bi, bj, si, sj, rsi, rsj);
final ri = r.ri;
final rj = r.rj;
sepAxis.negate(r.ni);
res[j].normal.negate(q);
q.scale(res[j].depth, q);
res[j].point.vadd(q, ri);
rj.copy(res[j].point);
// Contact points are in world coordinates. Transform back to relative
ri.vsub(xi, ri);
rj.vsub(xj, rj);
// Make relative to bodies
ri.vadd(xi, ri);
ri.vsub(bi.position, ri);
rj.vadd(xj, rj);
rj.vsub(bj.position, rj);
result.add(r);
numContacts++;
if (!enableFrictionReduction) {
createFrictionEquationsFromContact(r, frictionResult);
}
}
if (enableFrictionReduction && numContacts != 0) {
createFrictionFromAverage(numContacts);
}
}
return false;
}