]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rsurf.c
implemented r_glsl_water cvar (refraction and reflection rendering)
[xonotic/darkplaces.git] / gl_rsurf.c
index db9cc5459c272b2d191e0e9f6875d942d39f5b2e..cdd439266453dcd5171cf8685559cde40d4eff6f 100644 (file)
@@ -404,7 +404,7 @@ void R_DrawPortals(void)
        }
 }
 
-void R_View_WorldVisibility(void)
+void R_View_WorldVisibility(qboolean forcenovis)
 {
        int i, j, *mark;
        mleaf_t *leaf;
@@ -430,7 +430,7 @@ void R_View_WorldVisibility(void)
 
                // if floating around in the void (no pvs data available, and no
                // portals available), simply use all on-screen leafs.
-               if (!viewleaf || viewleaf->clusterindex < 0)
+               if (!viewleaf || viewleaf->clusterindex < 0 || forcenovis)
                {
                        // no visibility method: (used when floating around in the void)
                        // simply cull each leaf to the frustum (view pyramid)
@@ -524,9 +524,20 @@ void R_Q1BSP_DrawSky(entity_render_t *ent)
        if (ent->model == NULL)
                return;
        if (ent == r_refdef.worldentity)
-               R_DrawWorldSurfaces(true, true, false);
+               R_DrawWorldSurfaces(true, true, false, false);
        else
-               R_DrawModelSurfaces(ent, true, true, false);
+               R_DrawModelSurfaces(ent, true, true, false, false);
+}
+
+void R_Q1BSP_DrawAddWaterPlanes(entity_render_t *ent)
+{
+       model_t *model = ent->model;
+       if (model == NULL)
+               return;
+       if (ent == r_refdef.worldentity)
+               R_DrawWorldSurfaces(false, false, false, true);
+       else
+               R_DrawModelSurfaces(ent, false, false, false, true);
 }
 
 void R_Q1BSP_Draw(entity_render_t *ent)
@@ -535,9 +546,9 @@ void R_Q1BSP_Draw(entity_render_t *ent)
        if (model == NULL)
                return;
        if (ent == r_refdef.worldentity)
-               R_DrawWorldSurfaces(false, true, false);
+               R_DrawWorldSurfaces(false, true, false, false);
        else
-               R_DrawModelSurfaces(ent, false, true, false);
+               R_DrawModelSurfaces(ent, false, true, false, false);
 }
 
 void R_Q1BSP_DrawDepth(entity_render_t *ent)
@@ -546,9 +557,9 @@ void R_Q1BSP_DrawDepth(entity_render_t *ent)
        if (model == NULL)
                return;
        if (ent == r_refdef.worldentity)
-               R_DrawWorldSurfaces(false, false, true);
+               R_DrawWorldSurfaces(false, false, true, false);
        else
-               R_DrawModelSurfaces(ent, false, false, true);
+               R_DrawModelSurfaces(ent, false, false, true, false);
 }
 
 typedef struct r_q1bsp_getlightinfo_s
@@ -930,6 +941,8 @@ void R_Q1BSP_CompileShadowVolume(entity_render_t *ent, vec3_t relativelightorigi
        r_shadow_compilingrtlight->static_meshchain_shadow = Mod_ShadowMesh_Finish(r_main_mempool, r_shadow_compilingrtlight->static_meshchain_shadow, false, false, true);
 }
 
+extern cvar_t r_polygonoffset_submodel_factor;
+extern cvar_t r_polygonoffset_submodel_offset;
 void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin, vec3_t relativelightdirection, float lightradius, int modelnumsurfaces, const int *modelsurfacelist, const vec3_t lightmins, const vec3_t lightmaxs)
 {
        model_t *model = ent->model;
@@ -940,6 +953,8 @@ void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin,
        if (!BoxesOverlap(model->normalmins, model->normalmaxs, lightmins, lightmaxs))
                return;
        R_UpdateAllTextureInfo(ent);
+       if (ent->model->brush.submodel)
+               GL_PolygonOffset(r_refdef.shadowpolygonfactor + r_polygonoffset_submodel_factor.value, r_refdef.shadowpolygonoffset + r_polygonoffset_submodel_offset.value);
        if (model->brush.shadowmesh)
        {
                R_Shadow_PrepareShadowMark(model->brush.shadowmesh->numtriangles);
@@ -968,6 +983,8 @@ void R_Q1BSP_DrawShadowVolume(entity_render_t *ent, vec3_t relativelightorigin,
                }
                R_Shadow_VolumeFromList(model->surfmesh.num_vertices, model->surfmesh.num_triangles, rsurface.vertex3f, model->surfmesh.data_element3i, model->surfmesh.data_neighbor3i, relativelightorigin, relativelightdirection, projectdistance, numshadowmark, shadowmarklist);
        }
+       if (ent->model->brush.submodel)
+               GL_PolygonOffset(r_refdef.shadowpolygonfactor, r_refdef.shadowpolygonoffset);
 }
 
 #define BATCHSIZE 1024
@@ -1138,6 +1155,11 @@ void R_ReplaceWorldTexture (void)
        int                     i;
        const char      *r, *newt;
        skinframe_t *skinframe;
+       if (!r_refdef.worldmodel)
+       {
+               Con_Printf("There is no worldmodel\n");
+               return;
+       }
        m = r_refdef.worldmodel;
 
        if(Cmd_Argc() < 2)
@@ -1180,6 +1202,11 @@ void R_ListWorldTextures (void)
        model_t         *m;
        texture_t       *t;
        int                     i;
+       if (!r_refdef.worldmodel)
+       {
+               Con_Printf("There is no worldmodel\n");
+               return;
+       }
        m = r_refdef.worldmodel;
 
        Con_Print("Worldmodel textures :\n");