Previously, line-based portals accessed global
ceilingclip/floorclip before the current seg was rendered.
This means clipping for such portals would be based on
whichever seg happened to render before. Additionally,
ceilingclip/floorclip have more to do with clipping the
visplanes than the height of the wall between (for
instance, using these values doesn't work for two-sided
lines that create a "window" between the planes). The
correct approach that should always work is using the
midtexture's height from inside of R_RenderSegLoop.
- Resetting portalcullsector fixes the major visual glitches
- Using 32 bits for nummasks and i fixes crashes when rendering lots of portals
# Conflicts:
# src/r_main.c
Vissprites are now only clipped against their respective portal's geometry obtained from their BSP run.
Additionally, if a portal is provided, they're clipped to the portal's clip boundaries.
The work on this branch should conclude after a pair of remaining glitches are fixed.
The drawnodes are now fully grouped in separate lists, and then sorted individually. This fixes sorting problems caused by portals belonging to differently perceived scales (skyboxes for example).
Drawsegs and vissprite/drawnode sorting require the viewz, so the viewz is stored for each portal/view, and then restored when needed; without this, the rendering process erroneously sorts the elements, and draws some at wrong positions.
The skybox rendering process has been replaced with portals instead. Those are generated after the first BSP tree pass by looking for existing sky visplanes at the time, and their windows are used to define new portals.
The skybox portals are still incomplete and cause visual glitches when masked elements are involved.
Split portal-related code to its own source files.
Most of the 2-line-specific setup has been moved to the function which adds a 2-line case. The portals should render as they used to so far, anyway.