World:computeOverlaps

Edit

Detects which pairs of shapes in the world are near each other and could be colliding. After calling this function, the World:overlaps iterator can be used to iterate over the overlaps, and World:collide can be used to resolve a collision for the shapes (if any). Usually this is called automatically by World:update.

World:computeOverlaps()

Arguments

None

Returns

Nothing

Notes

This performs the "broad phase" culling of objects in the World, usually using a spatial hash or other acceleration structure like a quad tree or octree.

Example

world:computeOverlaps()
for shapeA, shapeB in world:overlaps() do
  local areColliding = world:collide(shapeA, shapeB)
  print(shapeA, shapeB, areColliding)
end

See also