Skip to main content

Module vision

Module vision 

Source
Expand description

Vision areas of a startpos (LINE_OF_SIGHT and CAMPAIGN_SHROUD records) and their quad tree encoding.

Vision lives on a square grid of half world units over the campaign map, rounded to whole cells (1357x1112 cells in Attila; both sides are stretched to fit the map exactly). The startpos stores an area as a quad tree over a power-of-two square that covers the grid, with its rows counted from the top:

  • A node with children is a byte with the code of each child in two bits, the first child in the lowest bits (1: mixed, 2: empty, 3: full), followed by its mixed children. Children are the top-left, top-right, bottom-left and bottom-right quarters.
  • A node without children (the 8x8 cells at the bottom of the tree) is a 0 byte followed by 8 bytes, one per row from the bottom, with the leftmost cell in the lowest bit. An empty area is a single such node.

Structs§

Vision
An area of the vision grid: a set of cells (column, row from the bottom).
VisionGrid
The vision grid of a campaign map.

Type Aliases§

WorldBounds
World bounds of an area: its corner closest to the origin and the opposite one.