etlegacy/etlegacy — pull request #87 by zturtleman (2014-09-15 08:53:54+00:00)
Title: renderers: fix decal projector culling

Fix for http://www.etlegacy.com/issues/557

The R_CullPointAndRadius call in RE_ProjectDecal has a comment which says "frustum cull the projector (fixme: this uses a stale frustum!)". By removing the save/restore viewparms before/after drawing head model scene, it now uses the head scene frustum instead of stale world frustum.

It's impossible to have the correct frustum in RE_ProjectDecal. The correct frustum cannot be generated before trap_R_RenderScene is called because the renderer doesn't have the view origin/axis, etc. So need to change the code to hold all the decal projectors and then cull them later in R_CullDecalProjectors.

----

Instead of using stale frustum to cull decal projects in RE_ProjectDecal (which no longer works now that save/restore viewparms was removed) and then culling them again with the current frustum; store up to 512
decal projectors per-frame and cull them later using the current frustum.

32-bit bitmasks are used to mark which projectors affect a surface, so in R_CullDecalProjectors put (up to 32) active decal projectors at the beginning of array.

512 decal projectors per-frame was picked at random. Might be excess or too low.

---

I merge the code into GLES and opengl2, but didn't compile it.