]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rsurf.c
renamed r_bloomstate to r_fb because it contains framebuffer settings
[xonotic/darkplaces.git] / gl_rsurf.c
index ed5534ae5abc6567b330527d5e6c28c2f3782a63..34aef9189799fe4466054248752bf1ee0fb7de38 100644 (file)
@@ -28,7 +28,7 @@ cvar_t r_ambient = {0, "r_ambient", "0", "brightens map, value is 0-128"};
 cvar_t r_lockpvs = {0, "r_lockpvs", "0", "disables pvs switching, allows you to walk around and inspect what is visible from a given location in the map (anything not visible from your current location will not be drawn)"};
 cvar_t r_lockvisibility = {0, "r_lockvisibility", "0", "disables visibility updates, allows you to walk around and inspect what is visible from a given viewpoint in the map (anything offscreen at the moment this is enabled will not be drawn)"};
 cvar_t r_useportalculling = {0, "r_useportalculling", "2", "improve framerate with r_novis 1 by using portal culling - still not as good as compiled visibility data in the map, but it helps (a value of 2 forces use of this even with vis data, which improves framerates in maps without too much complexity, but hurts in extremely complex maps, which is why 2 is not the default mode)"};
-cvar_t r_usesurfaceculling = {0, "r_usesurfaceculling", "1", "improve framerate by culling offscreen surfaces"};
+cvar_t r_usesurfaceculling = {0, "r_usesurfaceculling", "1", "skip off-screen surfaces (1 = cull surfaces if the map is likely to benefit, 2 = always cull surfaces)"};
 cvar_t r_q3bsp_renderskydepth = {0, "r_q3bsp_renderskydepth", "0", "draws sky depth masking in q3 maps (as in q1 maps), this means for example that sky polygons can hide other things"};
 
 /*
@@ -397,6 +397,29 @@ void R_DrawPortals(void)
        }
 }
 
+static void R_View_WorldVisibility_CullSurfaces(void)
+{
+       int surfaceindex;
+       int surfaceindexstart;
+       int surfaceindexend;
+       unsigned char *surfacevisible;
+       msurface_t *surfaces;
+       dp_model_t *model = r_refdef.scene.worldmodel;
+       if (!model)
+               return;
+       if (r_trippy.integer)
+               return;
+       if (r_usesurfaceculling.integer < 1)
+               return;
+       surfaceindexstart = model->firstmodelsurface;
+       surfaceindexend = surfaceindexstart + model->nummodelsurfaces;
+       surfaces = model->data_surfaces;
+       surfacevisible = r_refdef.viewcache.world_surfacevisible;
+       for (surfaceindex = surfaceindexstart;surfaceindex < surfaceindexend;surfaceindex++)
+               if (surfacevisible[surfaceindex] && R_CullBox(surfaces[surfaceindex].mins, surfaces[surfaceindex].maxs))
+                       surfacevisible[surfaceindex] = 0;
+}
+
 void R_View_WorldVisibility(qboolean forcenovis)
 {
        int i, j, *mark;
@@ -427,6 +450,7 @@ void R_View_WorldVisibility(qboolean forcenovis)
                                                r_refdef.viewcache.world_surfacevisible[*mark] = true;
                        }
                }
+               R_View_WorldVisibility_CullSurfaces();
                return;
        }
 
@@ -540,23 +564,7 @@ void R_View_WorldVisibility(qboolean forcenovis)
                }
        }
 
-       if (r_usesurfaceculling.integer)
-       {
-               int k = model->firstmodelsurface;
-               int l = k + model->nummodelsurfaces;
-               unsigned char *visible = r_refdef.viewcache.world_surfacevisible;
-               msurface_t *surfaces = model->data_surfaces;
-               msurface_t *surface;
-               for (;k < l;k++)
-               {
-                       if (visible[k])
-                       {
-                               surface = surfaces + k;
-                               if (R_CullBox(surface->mins, surface->maxs))
-                                       visible[k] = false;
-                       }
-               }
-}
+        R_View_WorldVisibility_CullSurfaces();
 }
 
 void R_Q1BSP_DrawSky(entity_render_t *ent)
@@ -581,7 +589,7 @@ void R_Q1BSP_DrawAddWaterPlanes(entity_render_t *ent)
        if (ent == r_refdef.scene.worldentity)
                RSurf_ActiveWorldEntity();
        else
-               RSurf_ActiveModelEntity(ent, false, false, false);
+               RSurf_ActiveModelEntity(ent, true, false, false);
 
        surfaces = model->data_surfaces;
        flagsmask = MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_REFLECTION | MATERIALFLAG_CAMERA;
@@ -1353,6 +1361,8 @@ void R_Q1BSP_CompileShadowMap(entity_render_t *ent, vec3_t relativelightorigin,
        int surfacelistindex;
        int sidetotals[6] = { 0, 0, 0, 0, 0, 0 }, sidemasks = 0;
        int i;
+       if (!model->brush.shadowmesh)
+               return;
        r_shadow_compilingrtlight->static_meshchain_shadow_shadowmap = Mod_ShadowMesh_Begin(r_main_mempool, 32768, 32768, NULL, NULL, NULL, false, false, true);
        R_Shadow_PrepareShadowSides(model->brush.shadowmesh->numtriangles);
        for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
@@ -1494,9 +1504,9 @@ void R_Q1BSP_DrawLight(entity_render_t *ent, int numsurfaces, const int *surface
                                ;
                        // now figure out what to do with this particular range of surfaces
                        // VorteX: added MATERIALFLAG_NORTLIGHT
-                       if ((rsurface.texture->currentmaterialflags & (MATERIALFLAG_WALL + MATERIALFLAG_NORTLIGHT)) != MATERIALFLAG_WALL)
+                       if ((rsurface.texture->currentmaterialflags & (MATERIALFLAG_WALL | MATERIALFLAG_FULLBRIGHT | MATERIALFLAG_NORTLIGHT)) != MATERIALFLAG_WALL)
                                continue;
-                       if (r_waterstate.renderingscene && (rsurface.texture->currentmaterialflags & (MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_REFLECTION | MATERIALFLAG_CAMERA)))
+                       if (r_fb.water.renderingscene && (rsurface.texture->currentmaterialflags & (MATERIALFLAG_WATERSHADER | MATERIALFLAG_REFRACTION | MATERIALFLAG_REFLECTION | MATERIALFLAG_CAMERA)))
                                continue;
                        if (rsurface.texture->currentmaterialflags & MATERIALFLAGMASK_DEPTHSORTED)
                        {