]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_rmain.c
gl_rmain: Duplicate the lightmap update code to avoid the extra check for non-world...
[xonotic/darkplaces.git] / gl_rmain.c
index 0526bc92baa125c9c2bf95e4f3d9fada5cf06da1..1cca3cae6ae1a527d1e7d808df693ff4a5e2f38b 100644 (file)
@@ -3189,7 +3189,7 @@ static void gl_main_shutdown(void)
        r_texture_numcubemaps = 0;
        //r_texture_fogintensity = NULL;
        memset(&r_fb, 0, sizeof(r_fb));
-       R_GLSL_Restart_f(&cmd_client);
+       R_GLSL_Restart_f(&cmd_local);
 
        r_glsl_permutation = NULL;
        memset(r_glsl_permutationhash, 0, sizeof(r_glsl_permutationhash));
@@ -4071,6 +4071,11 @@ static void R_View_UpdateEntityVisible (void)
                for (i = 0;i < r_refdef.scene.numentities;i++)
                {
                        ent = r_refdef.scene.entities[i];
+                       if (r_refdef.viewcache.world_novis && !(ent->flags & RENDER_VIEWMODEL))
+                       {
+                               r_refdef.viewcache.entityvisible[i] = false;
+                               continue;
+                       }
                        if (!(ent->flags & renderimask))
                        if (!R_CullBox(ent->mins, ent->maxs) || (ent->model && ent->model->type == mod_sprite && (ent->model->sprite.sprnum_type == SPR_LABEL || ent->model->sprite.sprnum_type == SPR_LABEL_SCALE)))
                        if ((ent->flags & (RENDER_NODEPTHTEST | RENDER_WORLDOBJECT | RENDER_VIEWMODEL)) || r_refdef.scene.worldmodel->brush.BoxTouchingVisibleLeafs(r_refdef.scene.worldmodel, r_refdef.viewcache.world_leafvisible, ent->mins, ent->maxs))
@@ -4139,17 +4144,7 @@ static void R_DrawModels(void)
                        continue;
                ent = r_refdef.scene.entities[i];
                r_refdef.stats[r_stat_entities]++;
-               /*
-               if (ent->model && !strncmp(ent->model->name, "models/proto_", 13))
-               {
-                       vec3_t f, l, u, o;
-                       Matrix4x4_ToVectors(&ent->matrix, f, l, u, o);
-                       Con_Printf("R_DrawModels\n");
-                       Con_Printf("model %s O %f %f %f F %f %f %f L %f %f %f U %f %f %f\n", ent->model->name, o[0], o[1], o[2], f[0], f[1], f[2], l[0], l[1], l[2], u[0], u[1], u[2]);
-                       Con_Printf("group: %i %f %i %f %i %f %i %f\n", ent->framegroupblend[0].frame, ent->framegroupblend[0].lerp, ent->framegroupblend[1].frame, ent->framegroupblend[1].lerp, ent->framegroupblend[2].frame, ent->framegroupblend[2].lerp, ent->framegroupblend[3].frame, ent->framegroupblend[3].lerp);
-                       Con_Printf("blend: %i %f %i %f %i %f %i %f %i %f %i %f %i %f %i %f\n", ent->frameblend[0].subframe, ent->frameblend[0].lerp, ent->frameblend[1].subframe, ent->frameblend[1].lerp, ent->frameblend[2].subframe, ent->frameblend[2].lerp, ent->frameblend[3].subframe, ent->frameblend[3].lerp, ent->frameblend[4].subframe, ent->frameblend[4].lerp, ent->frameblend[5].subframe, ent->frameblend[5].lerp, ent->frameblend[6].subframe, ent->frameblend[6].lerp, ent->frameblend[7].subframe, ent->frameblend[7].lerp);
-               }
-               */
+
                if (ent->model && ent->model->Draw != NULL)
                        ent->model->Draw(ent);
                else
@@ -5686,7 +5681,7 @@ void R_RenderView(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, i
        rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveModelEntity
 
        if(R_CompileShader_CheckStaticParms())
-               R_GLSL_Restart_f(&cmd_client);
+               R_GLSL_Restart_f(&cmd_local);
 
        if (!r_drawentities.integer)
                r_refdef.scene.numentities = 0;
@@ -10022,26 +10017,6 @@ void R_DrawModelSurfaces(entity_render_t *ent, qbool skysurfaces, qbool writedep
        surfaces = model->data_surfaces;
        update = model->brushq1.lightmapupdateflags;
 
-       // update light styles
-       if (!skysurfaces && !depthonly && !prepass && model->brushq1.num_lightstyles && r_refdef.scene.lightmapintensity > 0)
-       {
-               model_brush_lightstyleinfo_t *style;
-               // Iterate over each active style
-               for (i = 0, style = model->brushq1.data_lightstyleinfo;i < model->brushq1.num_lightstyles;i++, style++)
-               {
-                       if (style->value != r_refdef.scene.lightstylevalue[style->style])
-                       {
-                               int *list = style->surfacelist;
-                               style->value = r_refdef.scene.lightstylevalue[style->style];
-                               // Iterate over every surface this style applies to
-                               for (j = 0;j < style->numsurfaces;j++)
-                                       // Update brush entities even if not visible otherwise they'll render solid black.
-                                       if(r_refdef.viewcache.world_surfacevisible[list[j]] || ent != r_refdef.scene.worldentity)
-                                               update[list[j]] = true;
-                       }
-               }
-       }
-
        flagsmask = skysurfaces ? MATERIALFLAG_SKY : MATERIALFLAG_WALL;
 
        if (debug)
@@ -10060,6 +10035,25 @@ void R_DrawModelSurfaces(entity_render_t *ent, qbool skysurfaces, qbool writedep
        // add visible surfaces to draw list
        if (ent == r_refdef.scene.worldentity)
        {
+               // update light styles
+               if (!skysurfaces && !depthonly && !prepass && model->brushq1.num_lightstyles && r_refdef.scene.lightmapintensity > 0)
+               {
+                       model_brush_lightstyleinfo_t *style;
+                       // Iterate over each active style
+                       for (i = 0, style = model->brushq1.data_lightstyleinfo;i < model->brushq1.num_lightstyles;i++, style++)
+                       {
+                               if (style->value != r_refdef.scene.lightstylevalue[style->style])
+                               {
+                                       int *list = style->surfacelist;
+                                       style->value = r_refdef.scene.lightstylevalue[style->style];
+                                       // Iterate over every surface this style applies to
+                                       for (j = 0;j < style->numsurfaces;j++)
+                                               // Update brush entities even if not visible otherwise they'll render solid black.
+                                               if(r_refdef.viewcache.world_surfacevisible[list[j]])
+                                                       update[list[j]] = true;
+                               }
+                       }
+               }
                // for the world entity, check surfacevisible
                for (i = 0;i < model->nummodelsurfaces;i++)
                {
@@ -10076,6 +10070,23 @@ void R_DrawModelSurfaces(entity_render_t *ent, qbool skysurfaces, qbool writedep
        }
        else
        {
+               // update light styles
+               if (!skysurfaces && !depthonly && !prepass && model->brushq1.num_lightstyles && r_refdef.scene.lightmapintensity > 0)
+               {
+                       model_brush_lightstyleinfo_t *style;
+                       // Iterate over each active style
+                       for (i = 0, style = model->brushq1.data_lightstyleinfo;i < model->brushq1.num_lightstyles;i++, style++)
+                       {
+                               if (style->value != r_refdef.scene.lightstylevalue[style->style])
+                               {
+                                       int *list = style->surfacelist;
+                                       style->value = r_refdef.scene.lightstylevalue[style->style];
+                                       // Iterate over every surface this style applies to
+                                       for (j = 0;j < style->numsurfaces;j++)
+                                               update[list[j]] = true;
+                               }
+                       }
+               }
                // add all surfaces
                for (i = 0; i < model->nummodelsurfaces; i++)
                        r_surfacelist[numsurfacelist++] = surfaces + model->sortedmodelsurfaces[i];
@@ -10089,14 +10100,10 @@ void R_DrawModelSurfaces(entity_render_t *ent, qbool skysurfaces, qbool writedep
        // update lightmaps if needed
        if (update)
        {
-               int updated = 0;
                for (j = model->firstmodelsurface, endj = model->firstmodelsurface + model->nummodelsurfaces;j < endj;j++)
                {
                        if (update[j])
-                       {
-                               updated++;
                                R_BuildLightMap(ent, surfaces + j);
-                       }
                }
        }