run method
void
run()
Run collision detection for the current state of items.
Implementation
void run() {
final potentials = broadphase.query();
potentials.forEach((tuple) {
final itemA = tuple.a;
final itemB = tuple.b;
if (itemA.possiblyIntersects(itemB)) {
final intersectionPoints = intersections(itemA, itemB);
if (intersectionPoints.isNotEmpty) {
if (!itemA.collidingWith(itemB)) {
handleCollisionStart(intersectionPoints, itemA, itemB);
}
handleCollision(intersectionPoints, itemA, itemB);
} else if (itemA.collidingWith(itemB)) {
handleCollisionEnd(itemA, itemB);
}
} else if (itemA.collidingWith(itemB)) {
handleCollisionEnd(itemA, itemB);
}
});
// Handles callbacks for an ended collision that the broadphase didn't
// reports as a potential collision anymore.
_lastPotentials.difference(potentials).forEach((tuple) {
if (tuple.a.collidingWith(tuple.b)) {
handleCollisionEnd(tuple.a, tuple.b);
}
});
_lastPotentials
..clear()
..addAll(potentials);
}