queryBox

fun queryBox(left: Float, top: Float, right: Float, bottom: Float, found: Overlaps, targets: QueryTargets = QueryTargets.EVERYTHING): Int(source)

Finds everything of targets that reaches into the box from (left, top) to (right, bottom), writes it into found and returns how many. Touching the box's edge counts. Allocates nothing once found is big enough.

Samples

val world = PhysicsWorld()
repeat(5) { world.rigidBody(Shape.circle(4f), x = it * 20f, y = 0f) }
// Make one Overlaps and keep it: it grows when it has to, then allocates nothing.
val found = Overlaps()
val count = world.queryBox(left = 10f, top = -10f, right = 60f, bottom = 10f, found = found)
assertPrints(count, "3")
assertPrints(found, "Overlaps(rigidBodies=3, softBodies=0, solids=0)")