# `CauldronGPU.Sectors.Live.Geometry`
[🔗](https://github.com/jaman/cauldron/blob/v0.3.3/cauldron_gpu/lib/cauldron_gpu/sectors/live/geometry.ex#L2)

The surfaces of a sector map sector by sector, from its sectors and sides as they are
now: each sector's floors and ceilings over its subsectors' polygons
(`CauldronGPU.Sectors.Flats.polygons/1`), and the walls facing into it
(`CauldronGPU.Sectors.Walls`, with its pegging and sky rules). Floors and ceilings
whose picture marks a sky, and the upper walls left out between two sky ceilings
(from the lower ceiling up to the higher, facing into the higher sector), are sky
surfaces keyed `:sky`.

A surface is `{{:picture, id} | :sky, corners}`, each corner
`{position, normal, uv, {sector, contrast}}` in map coordinates (+Z up): `sector` the
sector it is lit by and `contrast` the light `-16`, `0` or `16` added for the wall's
direction.

    geometry = CauldronGPU.Sectors.Live.Geometry.new(map)
    CauldronGPU.Sectors.Live.Geometry.surfaces(geometry, [3, 7], sectors, sides, pictures, sky)
    CauldronGPU.Sectors.Live.Geometry.neighbours(geometry, 3)

# `corner`

```elixir
@type corner() ::
  {{number(), number(), number()}, {number(), number(), number()},
   {number(), number()}, {non_neg_integer(), integer()}}
```

# `surface`

```elixir
@type surface() :: {{:picture, non_neg_integer()} | :sky, [corner()]}
```

# `t`

```elixir
@type t() :: %CauldronGPU.Sectors.Live.Geometry{
  lines: %{required(non_neg_integer()) =&gt; [non_neg_integer()]},
  map: Cauldron2D.Sectors.Map.t(),
  neighbours: %{required(non_neg_integer()) =&gt; MapSet.t(non_neg_integer())},
  polygons: %{
    required(non_neg_integer()) =&gt; [CauldronGPU.Sectors.Flats.polygon()]
  }
}
```

# `neighbours`

```elixir
@spec neighbours(t(), non_neg_integer()) :: MapSet.t(non_neg_integer())
```

The sectors sharing a two-sided line with `sector`.

# `new`

```elixir
@spec new(Cauldron2D.Sectors.Map.t()) :: t()
```

The geometry of `map`, which must carry a BSP.

# `surfaces`

```elixir
@spec surfaces(
  t(),
  [non_neg_integer()],
  tuple(),
  tuple(),
  Cauldron2D.Sectors.Pictures.t(),
  MapSet.t()
) ::
  %{required(non_neg_integer()) =&gt; [surface()]}
```

The surfaces of each of `wanted`, as `%{sector => surfaces}`, given the map's
`sectors` and `sides` as they are now; `sky` is the set of picture ids that mark a sky.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
