planeParticle method

bool planeParticle(
  1. Plane sj,
  2. Particle si,
  3. Vec3 xj,
  4. Vec3 xi,
  5. Quaternion qj,
  6. Quaternion qi,
  7. Body bj,
  8. Body bi, [
  9. Shape? rsi,
  10. Shape? rsj,
  11. bool justTest = false,
])

Implementation

bool planeParticle(
  Plane sj,
  Particle si,
  Vec3 xj,
  Vec3 xi,
  Quaternion qj,
  Quaternion qi,
  Body bj,
  Body bi,
  [
    Shape? rsi,
    Shape? rsj,
    bool justTest = false
]){
  final normal = _particlePlaneNormal;
  normal.set(0, 0, 1);
  bj.quaternion.vmult(normal, normal); // Turn normal according to plane orientation
  final relpos = _particlePlaneRelpos;
  xi.vsub(bj.position, relpos);
  final dot = normal.dot(relpos);
  if (dot <= 0.0) {
    if (justTest) {
      return true;
    }

    final r = createContactEquation(bi, bj, si, sj, rsi, rsj);
    r.ni.copy(normal); // Contact normal is the plane normal
    r.ni.negate(r.ni);
    r.ri.set(0, 0, 0); // Center of particle

    // Get particle position projected on plane
    final projected = _particlePlaneProjected;
    normal.scale(normal.dot(xi), projected);
    xi.vsub(projected, projected);

    // rj is now the projected world position minus plane position
    r.rj.copy(projected);
    result.add(r);
    createFrictionEquationsFromContact(r, frictionResult);
  }
  return false;
}