]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - r_shadow.c
334
[xonotic/darkplaces.git] / r_shadow.c
index 70e4aab7e8c06505a3a82974d87c06ebba2054d1..c447789acd0a02fc37adc589532b62c1a20c8986 100644 (file)
@@ -199,10 +199,6 @@ cvar_t r_editlights_quakelightsizescale = {CVAR_SAVE, "r_editlights_quakelightsi
 cvar_t r_editlights_rtlightssizescale = {CVAR_SAVE, "r_editlights_rtlightssizescale", "0.7"};
 cvar_t r_editlights_rtlightscolorscale = {CVAR_SAVE, "r_editlights_rtlightscolorscale", "2"};
 
-int c_rt_lights, c_rt_clears, c_rt_scissored;
-int c_rt_shadowmeshes, c_rt_shadowtris, c_rt_lightmeshes, c_rt_lighttris;
-int c_rtcached_shadowmeshes, c_rtcached_shadowtris;
-
 float r_shadow_attenpower, r_shadow_attenscale;
 
 rtlight_t *r_shadow_compilingrtlight;
@@ -882,10 +878,6 @@ void R_Shadow_Stage_Begin(void)
        qglEnable(GL_CULL_FACE);
        GL_Scissor(r_view_x, r_view_y, r_view_width, r_view_height);
        r_shadowstage = SHADOWSTAGE_NONE;
-
-       c_rt_lights = c_rt_clears = c_rt_scissored = 0;
-       c_rt_shadowmeshes = c_rt_shadowtris = c_rt_lightmeshes = c_rt_lighttris = 0;
-       c_rtcached_shadowmeshes = c_rtcached_shadowtris = 0;
 }
 
 void R_Shadow_Stage_ShadowVolumes(void)
@@ -2372,16 +2364,16 @@ void R_DrawRTLight(rtlight_t *rtlight, int visiblevolumes)
                VectorCopy(rtlight->cullmins, cullmins);
                VectorCopy(rtlight->cullmaxs, cullmaxs);
        }
-       else if (cl.worldmodel && cl.worldmodel->GetLightInfo)
+       else if (r_refdef.worldmodel && r_refdef.worldmodel->GetLightInfo)
        {
                // dynamic light, world available and can receive realtime lighting
                // if the light box is offscreen, skip it right away
                if (R_CullBox(cullmins, cullmaxs))
                        return;
                // calculate lit surfaces and clusters
-               R_Shadow_EnlargeClusterBuffer(cl.worldmodel->brush.num_pvsclusters);
-               R_Shadow_EnlargeSurfaceBuffer(cl.worldmodel->nummodelsurfaces); 
-               cl.worldmodel->GetLightInfo(&cl_entities[0].render, rtlight->shadoworigin, rtlight->radius, cullmins, cullmaxs, r_shadow_buffer_clusterlist, r_shadow_buffer_clusterpvs, &numclusters, r_shadow_buffer_surfacelist, r_shadow_buffer_surfacepvs, &numsurfaces);
+               R_Shadow_EnlargeClusterBuffer(r_refdef.worldmodel->brush.num_pvsclusters);
+               R_Shadow_EnlargeSurfaceBuffer(r_refdef.worldmodel->nummodelsurfaces); 
+               r_refdef.worldmodel->GetLightInfo(&cl_entities[0].render, rtlight->shadoworigin, rtlight->radius, cullmins, cullmaxs, r_shadow_buffer_clusterlist, r_shadow_buffer_clusterpvs, &numclusters, r_shadow_buffer_surfacelist, r_shadow_buffer_surfacepvs, &numsurfaces);
                clusterlist = r_shadow_buffer_clusterlist;
                clusterpvs = r_shadow_buffer_clusterpvs;
                surfacelist = r_shadow_buffer_surfacelist;
@@ -2461,7 +2453,7 @@ void R_DrawRTLight(rtlight_t *rtlight, int visiblevolumes)
                                {
                                        if (!BoxesOverlap(ent->mins, ent->maxs, cullmins, cullmaxs))
                                                continue;
-                                       if (cl.worldmodel != NULL && cl.worldmodel->brush.BoxTouchingPVS != NULL && !cl.worldmodel->brush.BoxTouchingPVS(cl.worldmodel, clusterpvs, ent->mins, ent->maxs))
+                                       if (r_refdef.worldmodel != NULL && r_refdef.worldmodel->brush.BoxTouchingPVS != NULL && !r_refdef.worldmodel->brush.BoxTouchingPVS(r_refdef.worldmodel, clusterpvs, ent->mins, ent->maxs))
                                                continue;
                                }
                                if (!(ent->flags & RENDER_SHADOW) || !ent->model || !ent->model->DrawShadowVolume)
@@ -2529,7 +2521,7 @@ void R_ShadowVolumeLighting(int visiblevolumes)
        dlight_t *light;
        rmeshstate_t m;
 
-       if (cl.worldmodel && strncmp(cl.worldmodel->name, r_shadow_mapname, sizeof(r_shadow_mapname)))
+       if (r_refdef.worldmodel && strncmp(r_refdef.worldmodel->name, r_shadow_mapname, sizeof(r_shadow_mapname)))
                R_Shadow_EditLights_Reload_f();
 
        if (visiblevolumes)
@@ -2820,12 +2812,12 @@ void R_Shadow_LoadWorldLights(void)
        int n, a, style, shadow, flags;
        char name[MAX_QPATH], cubemapname[MAX_QPATH], *lightsstring, *s, *t;
        float origin[3], radius, color[3], angles[3], corona, coronasizescale, ambientscale, diffusescale, specularscale;
-       if (cl.worldmodel == NULL)
+       if (r_refdef.worldmodel == NULL)
        {
                Con_Print("No map loaded.\n");
                return;
        }
-       FS_StripExtension (cl.worldmodel->name, name, sizeof (name));
+       FS_StripExtension (r_refdef.worldmodel->name, name, sizeof (name));
        strlcat (name, ".rtlights", sizeof (name));
        lightsstring = FS_LoadFile(name, tempmempool, false);
        if (lightsstring)
@@ -2907,12 +2899,12 @@ void R_Shadow_SaveWorldLights(void)
        char line[1024];
        if (!r_shadow_worldlightchain)
                return;
-       if (cl.worldmodel == NULL)
+       if (r_refdef.worldmodel == NULL)
        {
                Con_Print("No map loaded.\n");
                return;
        }
-       FS_StripExtension (cl.worldmodel->name, name, sizeof (name));
+       FS_StripExtension (r_refdef.worldmodel->name, name, sizeof (name));
        strlcat (name, ".rtlights", sizeof (name));
        bufchars = bufmaxchars = 0;
        buf = NULL;
@@ -2953,12 +2945,12 @@ void R_Shadow_LoadLightsFile(void)
        int n, a, style;
        char name[MAX_QPATH], *lightsstring, *s, *t;
        float origin[3], radius, color[3], subtract, spotdir[3], spotcone, falloff, distbias;
-       if (cl.worldmodel == NULL)
+       if (r_refdef.worldmodel == NULL)
        {
                Con_Print("No map loaded.\n");
                return;
        }
-       FS_StripExtension (cl.worldmodel->name, name, sizeof (name));
+       FS_StripExtension (r_refdef.worldmodel->name, name, sizeof (name));
        strlcat (name, ".lights", sizeof (name));
        lightsstring = FS_LoadFile(name, tempmempool, false);
        if (lightsstring)
@@ -3004,18 +2996,18 @@ void R_Shadow_LoadWorldLightsFromMap_LightArghliteTyrlite(void)
        float origin[3], angles[3], radius, color[3], light[4], fadescale, lightscale, originhack[3], overridecolor[3], vec[4];
        char key[256], value[1024];
 
-       if (cl.worldmodel == NULL)
+       if (r_refdef.worldmodel == NULL)
        {
                Con_Print("No map loaded.\n");
                return;
        }
        // try to load a .ent file first
-       FS_StripExtension (cl.worldmodel->name, key, sizeof (key));
+       FS_StripExtension (r_refdef.worldmodel->name, key, sizeof (key));
        strlcat (key, ".ent", sizeof (key));
        data = entfiledata = FS_LoadFile(key, tempmempool, true);
        // and if that is not found, fall back to the bsp file entity string
        if (!data)
-               data = cl.worldmodel->brush.entities;
+               data = r_refdef.worldmodel->brush.entities;
        if (!data)
                return;
        for (entnum = 0;COM_ParseToken(&data, false) && com_token[0] == '{';entnum++)
@@ -3155,7 +3147,7 @@ void R_Shadow_LoadWorldLightsFromMap_LightArghliteTyrlite(void)
                        }
                        else if (!strcmp("style", key))
                                style = atoi(value);
-                       else if (cl.worldmodel->type == mod_brushq3)
+                       else if (r_refdef.worldmodel->type == mod_brushq3)
                        {
                                if (!strcmp("scale", key))
                                        lightscale = atof(value);
@@ -3254,9 +3246,9 @@ void R_Shadow_EditLights_Clear_f(void)
 
 void R_Shadow_EditLights_Reload_f(void)
 {
-       if (!cl.worldmodel)
+       if (!r_refdef.worldmodel)
                return;
-       strlcpy(r_shadow_mapname, cl.worldmodel->name, sizeof(r_shadow_mapname));
+       strlcpy(r_shadow_mapname, r_refdef.worldmodel->name, sizeof(r_shadow_mapname));
        R_Shadow_ClearWorldLights();
        R_Shadow_LoadWorldLights();
        if (r_shadow_worldlightchain == NULL)
@@ -3269,7 +3261,7 @@ void R_Shadow_EditLights_Reload_f(void)
 
 void R_Shadow_EditLights_Save_f(void)
 {
-       if (!cl.worldmodel)
+       if (!r_refdef.worldmodel)
                return;
        R_Shadow_SaveWorldLights();
 }