From cb312c5dacdb9cb93d05760eb3e58a47a0062e81 Mon Sep 17 00:00:00 2001 From: havoc Date: Wed, 14 Apr 2004 06:17:43 +0000 Subject: [PATCH] merged R_DrawWorld into DrawSky/Draw so that rmain can just call DrawSky and Draw on the world entity like any other git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4103 d7cf8633-e32d-0410-b094-e92efae38249 --- gl_rmain.c | 16 +++++++++--- gl_rsurf.c | 71 ++++++++++++++++++++++++------------------------------ 2 files changed, 44 insertions(+), 43 deletions(-) diff --git a/gl_rmain.c b/gl_rmain.c index 76123a6f..fad13e4c 100644 --- a/gl_rmain.c +++ b/gl_rmain.c @@ -688,12 +688,22 @@ void R_RenderScene(void) if (!intimerefresh && !r_speeds.integer) S_ExtraUpdate (); + GL_ShowTrisColor(0.025, 0.025, 0, 1); + if (world->model && world->model->DrawSky) + { + world->model->DrawSky(world); + R_TimeReport("worldsky"); + } + if (R_DrawBrushModelsSky()) R_TimeReport("bmodelsky"); - // must occur early because it can draw sky - R_DrawWorld(world); - R_TimeReport("world"); + GL_ShowTrisColor(0.05, 0.05, 0.05, 1); + if (world->model && world->model->Draw) + { + world->model->Draw(world); + R_TimeReport("world"); + } // don't let sound skip if going slow if (!intimerefresh && !r_speeds.integer) diff --git a/gl_rsurf.c b/gl_rsurf.c index 5adf08f6..8f146d73 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -1391,27 +1391,15 @@ void R_UpdateTextureInfo(entity_render_t *ent) } } -void R_PrepareSurfaces(entity_render_t *ent) +void R_UpdateLightmapInfo(entity_render_t *ent) { - int i, numsurfaces, *surfacevisframes; - model_t *model; - msurface_t *surf, *surfaces, **surfchain; - vec3_t modelorg; - - if (!ent->model) + int i; + msurface_t *surface, **surfacechain; + model_t *model = ent->model; + if (!model) return; - - model = ent->model; - Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg); - numsurfaces = model->brushq1.nummodelsurfaces; - surfaces = model->brushq1.surfaces + model->brushq1.firstmodelsurface; - surfacevisframes = model->brushq1.surfacevisframes + model->brushq1.firstmodelsurface; - - R_UpdateTextureInfo(ent); - if (r_dynamic.integer && !r_shadow_realtime_dlight.integer) R_MarkLights(ent); - if (model->brushq1.light_ambient != r_ambient.value) { model->brushq1.light_ambient = r_ambient.value; @@ -1425,12 +1413,28 @@ void R_PrepareSurfaces(entity_render_t *ent) if (model->brushq1.light_stylevalue[i] != d_lightstylevalue[model->brushq1.light_style[i]]) { model->brushq1.light_stylevalue[i] = d_lightstylevalue[model->brushq1.light_style[i]]; - for (surfchain = model->brushq1.light_styleupdatechains[i];*surfchain;surfchain++) - (**surfchain).cached_dlight = true; + for (surfacechain = model->brushq1.light_styleupdatechains[i];(surface = *surfacechain);surfacechain++) + surface->cached_dlight = true; } } } +} +void R_PrepareSurfaces(entity_render_t *ent) +{ + int i, numsurfaces, *surfacevisframes; + model_t *model; + msurface_t *surf, *surfaces; + vec3_t modelorg; + + if (!ent->model) + return; + + model = ent->model; + Matrix4x4_Transform(&ent->inversematrix, r_vieworigin, modelorg); + numsurfaces = model->brushq1.nummodelsurfaces; + surfaces = model->brushq1.surfaces + model->brushq1.firstmodelsurface; + surfacevisframes = model->brushq1.surfacevisframes + model->brushq1.firstmodelsurface; for (i = 0, surf = surfaces;i < numsurfaces;i++, surf++) { if (surfacevisframes[i] == r_framecount) @@ -1569,7 +1573,8 @@ void R_PrepareBrushModel(entity_render_t *ent) #endif surf->dlightframe = -1; } - R_PrepareSurfaces(ent); + R_UpdateTextureInfo(ent); + R_UpdateLightmapInfo(ent); } void R_SurfaceWorldNode (entity_render_t *ent) @@ -1743,27 +1748,9 @@ void R_WorldVisibility(entity_render_t *ent) R_SurfaceWorldNode (ent); else R_PortalWorldNode (ent, viewleaf); -} -void R_DrawWorld(entity_render_t *ent) -{ - if (ent->model == NULL) - return; - if (!ent->model->brushq1.num_leafs) - { - if (ent->model->DrawSky) - ent->model->DrawSky(ent); - if (ent->model->Draw) - ent->model->Draw(ent); - } - else - { - R_PrepareSurfaces(ent); - R_DrawSurfaces(ent, SURF_DRAWSKY); - R_DrawSurfaces(ent, SURF_DRAWTURB | SURF_LIGHTMAP); - if (r_drawportals.integer) - R_DrawPortals(ent); - } + if (r_drawportals.integer) + R_DrawPortals(ent); } void R_Model_Brush_DrawSky(entity_render_t *ent) @@ -1772,6 +1759,7 @@ void R_Model_Brush_DrawSky(entity_render_t *ent) return; if (ent != &cl_entities[0].render) R_PrepareBrushModel(ent); + R_PrepareSurfaces(ent); R_DrawSurfaces(ent, SURF_DRAWSKY); } @@ -1782,6 +1770,9 @@ void R_Model_Brush_Draw(entity_render_t *ent) c_bmodels++; if (ent != &cl_entities[0].render) R_PrepareBrushModel(ent); + R_PrepareSurfaces(ent); + R_UpdateTextureInfo(ent); + R_UpdateLightmapInfo(ent); R_DrawSurfaces(ent, SURF_DRAWTURB | SURF_LIGHTMAP); } -- 2.39.2