computeOverlaps.lua 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. return {
  2. tag = 'worldCollision',
  3. summary = 'Compute pairs of shapes that are close to each other.',
  4. description = [[
  5. Detects which pairs of shapes in the world are near each other and could be colliding. After
  6. calling this function, the `World:overlaps` iterator can be used to iterate over the overlaps,
  7. and `World:collide` can be used to resolve a collision for the shapes (if any). Usually this is
  8. called automatically by `World:update`.
  9. ]],
  10. arguments = {},
  11. returns = {},
  12. variants = {
  13. {
  14. arguments = {},
  15. returns = {}
  16. }
  17. },
  18. example = [[
  19. world:computeOverlaps()
  20. for shapeA, shapeB in world:overlaps() do
  21. local areColliding = world:collide(shapeA, shapeB)
  22. print(shapeA, shapeB, areColliding)
  23. end
  24. ]],
  25. notes = [[
  26. This performs the "broad phase" culling of objects in the World, usually using a spatial hash or
  27. other acceleration structure like a quad tree or octree.
  28. ]],
  29. related = {
  30. 'World:overlaps',
  31. 'World:collide',
  32. 'World:update'
  33. }
  34. }