pub(crate) fn sweep(
instances: Vec<BallInstance>,
) -> impl FnOnce(&mut World) -> Vec<BallInstance>Expand description
Retire the instances the camera cannot see: despawn each one and answer with the ones that went, each naming the ball it stood for.
The render world owns the camera and the instances, so the visibility test happens here: the gameplay world only names the live instances and reacts to the answer by despawning their bodies. An instance that is already gone is skipped.
What it answers is a list rather than a stream of its own: a sweep is one request naming the whole scene, and the caller is waiting for exactly one answer, so the answer is the request’s own.