QueryTargets
What a query looks at: RIGID_BODIES, SOFT_BODIES and SOLIDS, joined with plus, or EVERYTHING. Two are equal when they look at the same things.
toString names them, for example QueryTargets(RIGID_BODIES, SOLIDS).
Samples
val world = PhysicsWorld()
val wall = world.rigidBody(Shape.box(10f, 100f), x = 100f, y = 0f, kind = BodyKind.STATIC)
// Make one RayHit and keep it: a raycast then allocates nothing.
val hit = RayHit()
val found = world.raycast(fromX = 0f, fromY = 0f, toX = 200f, toY = 0f, hit = hit, targets = QueryTargets.RIGID_BODIES)
assertPrints(found, "true")
assertPrints(hit.kind, "RIGID_BODY")
assertPrints(hit.rigidBodyOrNull == wall, "true")
// It hit the wall's left face, at x = 95, facing back towards the ray's start.
assertPrints(hit.x, "95.0")
assertPrints(hit.normalX, "-1.0")
assertPrints(world.raycast(0f, 0f, 50f, 0f, hit), "false")
assertPrints(hit.kind == HitKind.NOTHING, "true")Content copied to clipboard