createJoint method

  1. @override
int createJoint(
  1. int bodyA,
  2. int bodyB,
  3. JointSettings3D settings
)
override

Joins bodyA to bodyB, or to the world when bodyB is 0; 0 when it cannot be made. Both must be bodies createBody made, not a character's body.

Implementation

@override
int createJoint(int bodyA, int bodyB, JointSettings3D settings) {
  // Bodies createBody made: not a character's.
  if (bodies[bodyA]?.character != 0 ||
      (bodyB != 0 && bodies[bodyB]?.character != 0)) {
    return 0;
  }
  if (bodyA == bodyB) return 0;
  if (settings.kind == JointKind3D.sixDof &&
      (settings.sixDofModes.length < 6 ||
          settings.sixDofMin.length < 6 ||
          settings.sixDofMax.length < 6)) {
    return 0;
  }
  final joint = FakeJoint3D._(_next++, bodyA, bodyB, settings);
  joints[joint.handle] = joint;
  return joint.handle;
}