A sector map's lines, and the bodies moving through it, sorted into square blocks so that movement and traces only look at what is near.
blockmap =
map
|> Cauldron2D.Sectors.Blockmap.build(size: 128)
|> Cauldron2D.Sectors.Blockmap.with_bodies([{:player, {1056.0, -3616.0}, 16.0}, ...])
Cauldron2D.Sectors.Blockmap.lines_near(blockmap, {x, y}, 16.0)
Cauldron2D.Sectors.Blockmap.bodies_near(blockmap, {x, y}, 16.0)Lines are filed once, when the blockmap is built; bodies move, so with_bodies/2 files
a fresh set and replaces the last, and put_body/2 and remove_body/2 file or unfile
one as it moves. A body is {id, {x, y}, radius}.
Summary
Functions
The bodies whose box overlaps a box of radius round point.
File the lines of map (a Cauldron2D.Sectors.Map). Option :size, the block's side, default 128.
The blocks a segment passes through, in order from from to to, as block numbers.
The indexes of lines filed in the blocks a box of radius round point touches.
File body, moving it if a body with its id is filed already.
Unfile the body with id, if one is filed.
The blockmap with bodies filed, replacing the ones filed before.
Types
Functions
The bodies whose box overlaps a box of radius round point.
@spec build(Cauldron2D.Sectors.Map.t(), keyword()) :: t()
File the lines of map (a Cauldron2D.Sectors.Map). Option :size, the block's side, default 128.
The blocks a segment passes through, in order from from to to, as block numbers.
@spec lines_near(t(), {number(), number()}, number()) :: [non_neg_integer()]
The indexes of lines filed in the blocks a box of radius round point touches.
File body, moving it if a body with its id is filed already.
Unfile the body with id, if one is filed.
The blockmap with bodies filed, replacing the ones filed before.