]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rsurf.c
Check bbox for overlap even on bmodels again (disabling it was a speed loss)
[xonotic/darkplaces.git] / gl_rsurf.c
index 465e124c1fa44c19f71ed4b39d5bd03663d625f1..6a9650118c678a1835636b540bd17d0cad98a346 100644 (file)
@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 static signed int blocklights[MAX_LIGHTMAP_SIZE*MAX_LIGHTMAP_SIZE*3]; // LordHavoc: *3 for colored lighting
 
-static byte templight[MAX_LIGHTMAP_SIZE*MAX_LIGHTMAP_SIZE*4];
+static qbyte templight[MAX_LIGHTMAP_SIZE*MAX_LIGHTMAP_SIZE*4];
 
 cvar_t r_ambient = {0, "r_ambient", "0"};
 cvar_t r_vertexsurfaces = {0, "r_vertexsurfaces", "0"};
@@ -168,7 +168,7 @@ void R_StainNode (mnode_t *node, model_t *model, vec3_t origin, float radius, in
        float ndist;
        msurface_t *surf, *endsurf;
        int sdtable[256], td, maxdist, maxdist2, maxdist3, i, s, t, smax, tmax, smax3, dist2, impacts, impactt, subtract, a, stained, cr, cg, cb, ca, ratio;
-       byte *bl;
+       qbyte *bl;
        vec3_t impact;
        // LordHavoc: use 64bit integer...  shame it's not very standardized...
 #if _MSC_VER || __BORLANDC__
@@ -262,9 +262,9 @@ loc0:
                                                                                cr = (((icolor[4] - icolor[0]) * ratio) >> 8) + icolor[0];
                                                                                cg = (((icolor[5] - icolor[1]) * ratio) >> 8) + icolor[1];
                                                                                cb = (((icolor[6] - icolor[2]) * ratio) >> 8) + icolor[2];
-                                                                               bl[0] = (byte) ((((cr - (int) bl[0]) * a) >> 8) + (int) bl[0]);
-                                                                               bl[1] = (byte) ((((cg - (int) bl[1]) * a) >> 8) + (int) bl[1]);
-                                                                               bl[2] = (byte) ((((cb - (int) bl[2]) * a) >> 8) + (int) bl[2]);
+                                                                               bl[0] = (qbyte) ((((cr - (int) bl[0]) * a) >> 8) + (int) bl[0]);
+                                                                               bl[1] = (qbyte) ((((cg - (int) bl[1]) * a) >> 8) + (int) bl[1]);
+                                                                               bl[2] = (qbyte) ((((cb - (int) bl[2]) * a) >> 8) + (int) bl[2]);
                                                                                stained = true;
                                                                        }
                                                                }
@@ -349,8 +349,8 @@ Combine and scale multiple lightmaps into the 8.8 format in blocklights
 */
 static void R_BuildLightMap (msurface_t *surf, int dlightchanged)
 {
-       int             smax, tmax, i, j, size, size3, shift, scale, maps, *bl, stride, l;
-       byte    *lightmap, *out, *stain;
+       int smax, tmax, i, j, size, size3, shift, scale, maps, *bl, stride, l;
+       qbyte *lightmap, *out, *stain;
 
        // update cached lighting info
        surf->cached_dlight = 0;
@@ -559,10 +559,7 @@ static int RSurfShader_Sky(int stage, msurface_t *s)
                        m.cg = 1;
                        m.cb = 1;
                        m.ca = 1;
-                       if (r_mergesky.integer)
-                               m.tex[0] = R_GetTexture(mergeskytexture);
-                       else
-                               m.tex[0] = R_GetTexture(solidskytexture);
+                       m.tex[0] = R_GetTexture(solidskytexture);
                        m.texcoords[0] = &svert[0].st[0];
                        m.texcoordstep[0] = sizeof(surfvert_t);
                        speedscale = cl.time * (8.0/128.0);
@@ -619,7 +616,7 @@ static int RSurfShader_Sky(int stage, msurface_t *s)
        }
        else if (stage == 1)
        {
-               if (skyrenderglquake && !r_mergesky.integer)
+               if (skyrenderglquake)
                {
                        memset(&m, 0, sizeof(m));
                        m.transparent = false;
@@ -753,7 +750,7 @@ static void RSurfShader_Water_Pass_Base(msurface_t *s)
        }
        if (s->dlightframe == r_framecount && !(s->flags & SURF_DRAWFULLBRIGHT))
                RSurf_Light(s->dlightbits, m.numverts);
-       if (fogenabled/* && m.blendfunc2 == GL_ONE_MINUS_SRC_ALPHA*/)
+       if (fogenabled && (s->flags & SURF_DRAWNOALPHA))
        {
                for (i = 0, sv = svert;i < m.numverts;i++, sv++)
                {
@@ -881,9 +878,10 @@ static int RSurfShader_Water(int stage, msurface_t *s)
                        RSurfShader_Water_Pass_Glow(s);
                return false;
        case 2:
-               if (fogenabled && (s->flags & SURF_DRAWNOALPHA))
+               if (fogenabled)
                {
-                       RSurfShader_Water_Pass_Fog(s);
+                       if (currentrenderentity->alpha * (s->flags & SURF_DRAWNOALPHA ? 1 : r_wateralpha.value) >= 1.0f)
+                               RSurfShader_Water_Pass_Fog(s);
                        return false;
                }
                else
@@ -1091,12 +1089,12 @@ static void RSurfShader_Wall_Pass_BaseLightmap(msurface_t *s)
 
 static void RSurfShader_Wall_Pass_BaseVertex(msurface_t *s)
 {
-       int                             i, size3;
-       float                   c[3], base[3], scale, diff[3], ifog;
-       surfvertex_t    *v;
-       surfvert_t              *sv;
-       rmeshinfo_t             m;
-       byte                    *lm;
+       int i, size3;
+       float c[3], base[3], scale, diff[3], ifog;
+       surfvertex_t *v;
+       surfvert_t *sv;
+       rmeshinfo_t m;
+       qbyte *lm;
 
        size3 = ((s->extents[0]>>4)+1)*((s->extents[1]>>4)+1)*3;
 
@@ -1428,6 +1426,8 @@ static void RSurfShader_Wall_Pass_Fog(msurface_t *s)
 
 static int RSurfShader_Wall_Fullbright(int stage, msurface_t *s)
 {
+       if (stage == 0)
+               c_brush_polys++;
        switch(stage)
        {
        case 0:
@@ -1444,6 +1444,8 @@ static int RSurfShader_Wall_Fullbright(int stage, msurface_t *s)
 
 static int RSurfShader_Wall_Vertex(int stage, msurface_t *s)
 {
+       if (stage == 0)
+               c_brush_polys++;
        switch(stage)
        {
        case 0:
@@ -1460,6 +1462,8 @@ static int RSurfShader_Wall_Vertex(int stage, msurface_t *s)
 
 static int RSurfShader_Wall_Lightmap(int stage, msurface_t *s)
 {
+       if (stage == 0)
+               c_brush_polys++;
        if (r_vertexsurfaces.integer)
        {
                switch(stage)
@@ -1810,7 +1814,7 @@ static void R_PVSWorldNode()
        msurface_t *surf, **mark, **endmark;
        mleaf_t *leaf;
        tinyplane_t plane;
-       byte *worldvis;
+       qbyte *worldvis;
 
        worldvis = Mod_LeafPVS (r_viewleaf, cl.worldmodel);