# Licensing

**This code should be released under GPL-3.0.** That is not optional bookkeeping
— it follows from how it was written.

## Why

Ultimate Doom Builder is GPL. Its source was read as a *behavioural
specification* for this project: `Configuration.cs` for the config format,
`UniversalParser.cs` for UDMF serialization, `General.cs` for config
enumeration, `WAD.cs` for container handling. Later phases will read
`Tools.cs`, `DrawGeometryMode.cs`, `SectorsMode.cs` and
`BuilderModes/VisualModes/` the same way.

Reimplementing GPL software from its source is legitimate. Doing so and then
licensing the result permissively is not. Keep it GPL and the whole approach —
which is the only way to get feature-for-feature parity — stays clean.

## What was and was not taken

**This has moved, and the file should say so.** It began as reimplementation
from observed behaviour. It is now, in places, a **direct translation**: the
hole-cutting in `triangulate.js` is UDB's `SplitOuterWithInner` line by line,
and `topology.js` ports `LinedefAngleSorter`, `Vector2D.GetAngle`,
`Angle2D.Normalized/Difference` and `Line2D.GetSideOfLine`. That was a
deliberate decision — a simplification of the first of those failed on 1.5-3%
of sectors where the faithful port fails on 1 in 19,100 — but it makes the GPL
obligation stronger, not weaker. No C# was copied and pasted; the algorithms
were translated to JavaScript with UDB's comments kept as citations. Either
way, GPL-3.0 is the only correct outcome.

**Data, not code:** UDB's `Assets/Common/Configurations` tree is parsed at
runtime by `dbconfig.js`. Those `.cfg` files are not redistributed in this
archive — `fetch-references.sh` retrieves them from upstream. If you ever ship
them with a build, they carry UDB's license and should be attributed.

**From deotg** (biwa, GPL): one idea — the outer-clockwise /
holes-counter-clockwise contour convention for sectors containing islands. No
code.

poly2tri was previously listed here as the intended triangulation library. It
is no longer used: UDB triangulates by **ear clipping**
(`Source/Core/Geometry/Triangulation.cs`, with `EarClipPolygon` and
`EarClipVertex`), and a different algorithm yields a different triangle set. For
a project whose whole premise is parity, following UDB matters more than
convenience — and it leaves the build step at zero dependencies, which was
always the point.

**Third-party sources consulted:**

| source | license | used for |
|---|---|---|
| Ultimate Doom Builder | GPL-3.0 | format spec, behaviour, and directly ported geometry |
| GZDoom | GPL-3.0 overall; `udmf.cpp` header is BSD-3-Clause | engine-side constraints, the UDMF specs |
| UZDoom | GPL-3.0-or-later (relicensed; pre-2026 code also BSD-3-Clause) | the target port's map loader |
| Freedoom | BSD-style | container test data, not redistributed |
| omgifol | MIT | corpus generation, not redistributed |

## Reference maps

The ZDoom maps used to calibrate and test this — 21 of them now, not the
original four — are Reese's own work and are deliberately excluded from every
archive, along with `demo-config.json` (derived from UDB's `.cfg` tree). They
are not test fixtures to be published; they are private artifacts that happened
to be the only way to verify float formatting, blank-line placement, and later
the triangulator.
