]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
added r_usesurfaceculling cvar which defaults on, this new code reduces
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 19 Mar 2011 22:36:02 +0000 (22:36 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 19 Mar 2011 22:36:02 +0000 (22:36 +0000)
the number of surfaces drawn each frame, which is not always a speed
gain but is usually helpful

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10943 d7cf8633-e32d-0410-b094-e92efae38249

gl_rsurf.c

index f04bb2b671f9839df434bbce644e9e5530a131f5..e28277663fbefb866bc0210f9729c5ee61587a54 100644 (file)
@@ -28,6 +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", "1", "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_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"};
 
 /*
@@ -532,6 +533,24 @@ 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;
+                       }
+               }
+}
 }
 
 void R_Q1BSP_DrawSky(entity_render_t *ent)
@@ -1579,6 +1598,7 @@ void GL_Surf_Init(void)
        Cvar_RegisterVariable(&r_lockpvs);
        Cvar_RegisterVariable(&r_lockvisibility);
        Cvar_RegisterVariable(&r_useportalculling);
+       Cvar_RegisterVariable(&r_usesurfaceculling);
        Cvar_RegisterVariable(&r_q3bsp_renderskydepth);
 
        Cmd_AddCommand ("r_replacemaptexture", R_ReplaceWorldTexture, "override a map texture for testing purposes");