To create PVS for a wad file (e.g. FOO.WAD) simply type:
glVIS first searches for a GWA file. If it finds it, it will work with
it. Otherwise it assumes that wad file contains "GL Nodes" and will work
with wad file. glVIS will save old file with extension .~gw for .gwa file
or .~wa for a .wad file.
Check lump name, if it's not "GL_PVS", the data is missing. If you want,
you can treat this case as empty lump, but you can also abort with error
(like Vavoom does).
Check lump size, if it's 0, it's empty lump. In this case you allocate
((numsubsectors + 7) / 8) * numsubsectors bytes and fill them
Otherwise PVS data is present, simply load it.
Unlike REJECT, vis data for a subsector is aligned to byte. Offset in data
for subsector i
is ((numsubsectors + 7) / 8) * i
is similar to that of REJECT. Example of checking if subsector i
byte *vis_data; // PVS lump
int view_sub; // Num of subsector, where the player is
vis = vis_data + (((numsubsectors + 7) / 8) * view_sub);
if (vis[i >> 3] & (1 << (i & 7)))
// Subsector is visible
// Subsector is not visible