VISI (MREA Section)

Within MREA resources, the VISI section stores a PVS indexed into an octree. This PVS is used to determine visibility/occlusion between cubic sections of the area and models, scripting entities, and lights in the scene.

Octree Nodes
The octree data is arranged in a Z-major depth-first hierarchy embedded with variable-length pointers to skip over children, permitting rapid child selection. Each node of the octree starts with a 1-byte header of classification bits. If at least one subdivide bit is set, the node is a branch and contains 1-7 pointers, addressed relative to the position after the pointers. One subdivision will have 1 pointer, two subdivisions will have 3 pointers, and three subdivisions will have 7 pointers. The first child pointer is implied to be 0x0. Pointer data type is specified in the header (8, 16, or 24 bits).

Leaf Nodes
Instead of child pointers, leaf nodes contain byte-packed bits indicating visibility. The bits are arranged from LSB to MSB per-byte. First are the bits relating static MREA geometry in-order of the first MREA section. Next are bits relating the scripted entities in the VISI entities table. Finally are the bits relating lights in order of the BABEDEAD section of the MREA. Following these is another set of bits for each light indicating if it's in-bounds of the octree or not.