computePointStates static method

void computePointStates(
  1. List<PointState> state1,
  2. List<PointState> state2,
  3. Manifold manifold1,
  4. Manifold manifold2,
)

Compute the point states given two manifolds. The states pertain to the transition from manifold1 to manifold2. So state1 is either persist or remove while state2 is either add or persist.

Implementation

static void computePointStates(
  List<PointState> state1,
  List<PointState> state2,
  Manifold manifold1,
  Manifold manifold2,
) {
  for (var i = 0; i < settings.maxManifoldPoints; i++) {
    state1[i] = PointState.nullState;
    state2[i] = PointState.nullState;
  }

  // Detect persists and removes.
  for (var i = 0; i < manifold1.pointCount; i++) {
    final id = manifold1.points[i].id;

    state1[i] = PointState.removeState;

    for (var j = 0; j < manifold2.pointCount; j++) {
      if (manifold2.points[j].id.isEqual(id)) {
        state1[i] = PointState.persistState;
        break;
      }
    }
  }

  // Detect persists and adds
  for (var i = 0; i < manifold2.pointCount; i++) {
    final id = manifold2.points[i].id;

    state2[i] = PointState.addState;

    for (var j = 0; j < manifold1.pointCount; j++) {
      if (manifold1.points[j].id.isEqual(id)) {
        state2[i] = PointState.persistState;
        break;
      }
    }
  }
}