Overlaps

class Overlaps(initialCapacity: Int = 16)(source)

What a point or box query found, filled in by PhysicsWorld.queryPoint and PhysicsWorld.queryBox. Make one and keep it: it only allocates when it has to grow, the first few times.

toString gives how many of each it found, for example Overlaps(rigidBodies=2, softBodies=0, solids=1).

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)")

Constructors

Link copied to clipboard
constructor(initialCapacity: Int = 16)

Properties

Link copied to clipboard

Number of rigid bodies found.

Link copied to clipboard
val size: Int

Number of things found in all.

Link copied to clipboard

Number of soft bodies found.

Link copied to clipboard

Number of solids found.

Functions

Link copied to clipboard

Returns true if it found body.

Link copied to clipboard

Returns the rigid body found at index.

Link copied to clipboard
fun softBodyAt(index: Int): SoftBody

Returns the soft body found at index.

Link copied to clipboard
fun solidAt(index: Int): Solid

Returns the solid found at index.

Link copied to clipboard
open override fun toString(): String