ZNODES

From ZDoom Wiki
Jump to navigation Jump to search

ZNODES is an optional lump built by the nodebuilder for a map in the Universal Doom Map Format. It contains data that correspond to the NODES, SSECTORS and SEGS lump from the classic binary map formats.

ZNODES are necessarily GL nodes, normal nodes are not supported. Given that ZDBSP is the only nodebuilder in existence that can parse UDMF maps, this requirement is reasonable. Nodes can be indifferently in the XGLN, ZGLN, XGL2, or ZGL2 formats, but no other. If the lump is not present, ZDoom will use its internal nodebuilder, which is an integrated version of ZDBSP.

GL nodes (“XGLN” or “ZGLN” signature)

DWORD NumSegs Number of segs
Repeat NumSegs times:
DWORD v1 Seg's first vertex
DWORD partner Seg's partner seg (0xFFFFFFFF if none)
WORD line The linedef this seg came from (0xFFFF if none)
BYTE side The linedef's side this seg came from (0=front, 1=back) (ignored if no line)

GL nodes (“XGL2” or “ZGL2” signature)

DWORD NumSegs Number of segs
Repeat NumSegs times:
DWORD v1 Seg's first vertex
DWORD partner Seg's partner seg (0xFFFFFFFF if none)
DWORD line The linedef this seg came from (0xFFFFFFFF if none)
BYTE side The linedef's side this seg came from (0=front, 1=back) (ignored if no line)

Unlike standard GL nodes, each seg's second vertex is not stored. This is because GL subsectors must form a closed area. In other words, one seg's second vertex is the same as the next seg's first vertex. The subsector information contains everything you need to know to close each area and start a new one.

Example: Suppose you have not read any segs yet, and the first subsector has four segs. Therefore, the second vertex for the first four segs can be determined to be:

Seg 0 Second vertex is Seg 1's first vertex
Seg 1 Second vertex is Seg 2's first vertex
Seg 2 Second vertex is Seg 3's first vertex
Seg 3 Second vertex is Seg 0's first vertex (because this is the last seg in the subsector)

So for each subsector, all but the last seg's second vertex will be the same as the next seg's first vertex. The last seg's second vertex will be the same as the first seg's first vertex.