]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rsurf.c
r_showtris/r_shownormals/r_showcollisionbrushes are no longer obscured
[xonotic/darkplaces.git] / gl_rsurf.c
index cdd439266453dcd5171cf8685559cde40d4eff6f..5cd7f27a3ebafa89394167a4eb3cc14e5a0bba9c 100644 (file)
@@ -414,11 +414,34 @@ void R_View_WorldVisibility(qboolean forcenovis)
        if (!model)
                return;
 
+       if (r_view.usecustompvs)
+       {
+               // clear the visible surface and leaf flags arrays
+               memset(r_viewcache.world_surfacevisible, 0, model->num_surfaces);
+               memset(r_viewcache.world_leafvisible, 0, model->brush.num_leafs);
+               r_viewcache.world_novis = false;
+
+               // simply cull each marked leaf to the frustum (view pyramid)
+               for (j = 0, leaf = model->brush.data_leafs;j < model->brush.num_leafs;j++, leaf++)
+               {
+                       // if leaf is in current pvs and on the screen, mark its surfaces
+                       if (CHECKPVSBIT(r_viewcache.world_pvsbits, leaf->clusterindex) && !R_CullBox(leaf->mins, leaf->maxs))
+                       {
+                               r_refdef.stats.world_leafs++;
+                               r_viewcache.world_leafvisible[j] = true;
+                               if (leaf->numleafsurfaces)
+                                       for (i = 0, mark = leaf->firstleafsurface;i < leaf->numleafsurfaces;i++, mark++)
+                                               r_viewcache.world_surfacevisible[*mark] = true;
+                       }
+               }
+               return;
+       }
+
        // if possible find the leaf the view origin is in
        viewleaf = model->brush.PointInLeaf ? model->brush.PointInLeaf(model, r_view.origin) : NULL;
        // if possible fetch the visible cluster bits
        if (!r_lockpvs.integer && model->brush.FatPVS)
-               model->brush.FatPVS(model, r_view.origin, 2, r_viewcache.world_pvsbits, sizeof(r_viewcache.world_pvsbits));
+               model->brush.FatPVS(model, r_view.origin, 2, r_viewcache.world_pvsbits, sizeof(r_viewcache.world_pvsbits), false);
 
        if (!r_lockvisibility.integer)
        {
@@ -524,9 +547,9 @@ void R_Q1BSP_DrawSky(entity_render_t *ent)
        if (ent->model == NULL)
                return;
        if (ent == r_refdef.worldentity)
-               R_DrawWorldSurfaces(true, true, false, false);
+               R_DrawWorldSurfaces(true, true, false, false, false);
        else
-               R_DrawModelSurfaces(ent, true, true, false, false);
+               R_DrawModelSurfaces(ent, true, true, false, false, false);
 }
 
 void R_Q1BSP_DrawAddWaterPlanes(entity_render_t *ent)
@@ -535,9 +558,9 @@ void R_Q1BSP_DrawAddWaterPlanes(entity_render_t *ent)
        if (model == NULL)
                return;
        if (ent == r_refdef.worldentity)
-               R_DrawWorldSurfaces(false, false, false, true);
+               R_DrawWorldSurfaces(false, false, false, true, false);
        else
-               R_DrawModelSurfaces(ent, false, false, false, true);
+               R_DrawModelSurfaces(ent, false, false, false, true, false);
 }
 
 void R_Q1BSP_Draw(entity_render_t *ent)
@@ -546,9 +569,9 @@ void R_Q1BSP_Draw(entity_render_t *ent)
        if (model == NULL)
                return;
        if (ent == r_refdef.worldentity)
-               R_DrawWorldSurfaces(false, true, false, false);
+               R_DrawWorldSurfaces(false, true, false, false, false);
        else
-               R_DrawModelSurfaces(ent, false, true, false, false);
+               R_DrawModelSurfaces(ent, false, true, false, false, false);
 }
 
 void R_Q1BSP_DrawDepth(entity_render_t *ent)
@@ -557,9 +580,19 @@ void R_Q1BSP_DrawDepth(entity_render_t *ent)
        if (model == NULL)
                return;
        if (ent == r_refdef.worldentity)
-               R_DrawWorldSurfaces(false, false, true, false);
+               R_DrawWorldSurfaces(false, false, true, false, false);
+       else
+               R_DrawModelSurfaces(ent, false, false, true, false, false);
+}
+
+void R_Q1BSP_DrawDebug(entity_render_t *ent)
+{
+       if (ent->model == NULL)
+               return;
+       if (ent == r_refdef.worldentity)
+               R_DrawWorldSurfaces(false, false, false, false, true);
        else
-               R_DrawModelSurfaces(ent, false, false, true, false);
+               R_DrawModelSurfaces(ent, false, false, false, false, true);
 }
 
 typedef struct r_q1bsp_getlightinfo_s