SEGS (an abbreviation for segments) is the name of a WAD lump which is a component of a level. It is normally generated automatically from other data for the level using a node builder tool.

Segs are segments of linedefs, and describe the portion of a linedef that borders the subsector that the seg belongs to.

Initially, one seg is created for each one-sided linedef, and two segs are created for each two-sided linedef (one for each side). If the area that a seg borders is later divided into two different subsectors, then a new vertex is created at the division point and the seg is split into two at that vertex. The segs are stored in sequential order corresponding to subsector number. The seg entries are referenced from the subsector entries, which are referenced from the nodes lump.

Seg structure[edit]

Doom level format
Offset Size (bytes) C99 type Description
0 2 int16_t Starting vertex number
2 2 int16_t Ending vertex number
4 2 int16_t Angle, full circle is -32768 to 32767.
6 2 int16_t Linedef number
8 2 int16_t Direction: 0 (same as linedef) or 1 (opposite of linedef)
10 2 int16_t Offset: distance along linedef to start of seg

The direction field may be interpreted as a "side flag": direction=0 indicates the seg runs along the "right" or front side of the linedef; direction=1 indicates it runs along the "left" or back side.

Note that the original source code utilizes the C type short, for a signed 2-byte integer, for each of the fields in this structure. This imposes a limit of 32768 vertices and linedefs in a map. Many limit-removing source ports and modern editing utilities change the interpretation of the vertex numbers and linedef number to unsigned in order to support larger maps with up to 65536 vertices and 65535 linedefs (one less linedef is available due to linedefs' inability to address more than 65535 sidedefs).

Drawsegs overflow[edit]

While constructing a frame, the segs to be drawn are stored for later rendering. In vanilla Doom, they are kept in a static array 256 elements long, and if a frame requires more segs than this, the excess segs are simply not drawn.

See also[edit]