From f912b4ab8bfb79c7b6d84d89f5fb03ecc32620b5 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Thu, 12 Jan 2017 19:09:13 +0100 Subject: [PATCH] Convert r_actualextralight global to a function --- src/swrenderer/line/r_line.cpp | 6 ++---- src/swrenderer/line/r_walldraw.cpp | 2 +- src/swrenderer/scene/r_light.cpp | 1 - src/swrenderer/scene/r_light.h | 3 ++- src/swrenderer/scene/r_opaque_pass.cpp | 13 ++++++------- src/swrenderer/scene/r_translucent_pass.cpp | 2 +- src/swrenderer/segments/r_drawsegment.cpp | 10 +++++----- src/swrenderer/things/r_playersprite.cpp | 3 +-- src/swrenderer/things/r_wallsprite.cpp | 2 +- 9 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/swrenderer/line/r_line.cpp b/src/swrenderer/line/r_line.cpp index 9398611cf..fb5c956d2 100644 --- a/src/swrenderer/line/r_line.cpp +++ b/src/swrenderer/line/r_line.cpp @@ -524,8 +524,7 @@ namespace swrenderer } else { - draw_segment->shade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, curline->frontsector->lightlevel) - + r_actualextralight); + draw_segment->shade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, curline->frontsector->lightlevel) + R_ActualExtraLight(foggy)); } if (draw_segment->bFogBoundary || draw_segment->maskedtexturecol != -1) @@ -938,8 +937,7 @@ namespace swrenderer if (fixedcolormap == NULL && fixedlightlev < 0) { - wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, frontsector->lightlevel) - + r_actualextralight); + wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, frontsector->lightlevel) + R_ActualExtraLight(foggy)); double GlobVis = r_WallVisibility; rw_lightleft = float(GlobVis / WallC.sz1); rw_lightstep = float((GlobVis / WallC.sz2 - rw_lightleft) / (WallC.sx2 - WallC.sx1)); diff --git a/src/swrenderer/line/r_walldraw.cpp b/src/swrenderer/line/r_walldraw.cpp index c5e1e036a..b23a7e602 100644 --- a/src/swrenderer/line/r_walldraw.cpp +++ b/src/swrenderer/line/r_walldraw.cpp @@ -464,7 +464,7 @@ namespace swrenderer lightlist_t *lit = &frontsector->e->XFloor.lightlist[i]; basecolormap = lit->extra_colormap; - wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(fogginess, *lit->p_lightlevel, lit->lightsource != NULL) + r_actualextralight); + wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(fogginess, *lit->p_lightlevel, lit->lightsource != NULL) + R_ActualExtraLight(foggy)); } ProcessNormalWall(WallC, x1, x2, up, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep); diff --git a/src/swrenderer/scene/r_light.cpp b/src/swrenderer/scene/r_light.cpp index 7a45d9377..7e82f33ca 100644 --- a/src/swrenderer/scene/r_light.cpp +++ b/src/swrenderer/scene/r_light.cpp @@ -51,7 +51,6 @@ namespace swrenderer FSpecialColormap *realfixedcolormap; bool foggy; // [RH] ignore extralight and fullbright? - int r_actualextralight; namespace { diff --git a/src/swrenderer/scene/r_light.h b/src/swrenderer/scene/r_light.h index e39b63067..9f96856d9 100644 --- a/src/swrenderer/scene/r_light.h +++ b/src/swrenderer/scene/r_light.h @@ -57,13 +57,14 @@ namespace swrenderer extern float r_TiltVisibility; extern double r_SpriteVisibility; - extern int r_actualextralight; extern bool foggy; extern int fixedlightlev; extern FSWColormap *fixedcolormap; extern FSpecialColormap *realfixedcolormap; extern FDynamicColormap *basecolormap; // [RH] Colormap for sector currently being drawn + inline int R_ActualExtraLight(bool fog) { return fog ? 0 : extralight << 4; } + void R_SetVisibility(double visibility); double R_GetVisibility(); diff --git a/src/swrenderer/scene/r_opaque_pass.cpp b/src/swrenderer/scene/r_opaque_pass.cpp index 7cdc30834..1d15ac11e 100644 --- a/src/swrenderer/scene/r_opaque_pass.cpp +++ b/src/swrenderer/scene/r_opaque_pass.cpp @@ -477,7 +477,6 @@ namespace swrenderer // [RH] set foggy flag foggy = level.fadeto || frontsector->ColorMap->Fade || (level.flags & LEVEL_HASFADETABLE); - r_actualextralight = foggy ? 0 : extralight << 4; // kg3D - fake lights if (fixedlightlev < 0 && frontsector->e && frontsector->e->XFloor.lightlist.Size()) @@ -506,7 +505,7 @@ namespace swrenderer frontsector->heightsec->GetTexture(sector_t::floor) == skyflatnum) ? VisiblePlaneList::Instance()->FindPlane(frontsector->ceilingplane, // killough 3/8/98 frontsector->GetTexture(sector_t::ceiling), - ceilinglightlevel + r_actualextralight, // killough 4/11/98 + ceilinglightlevel + R_ActualExtraLight(foggy), // killough 4/11/98 frontsector->GetAlpha(sector_t::ceiling), !!(frontsector->GetFlags(sector_t::ceiling) & PLANEF_ADDITIVE), frontsector->planes[sector_t::ceiling].xform, @@ -546,7 +545,7 @@ namespace swrenderer frontsector->heightsec->GetTexture(sector_t::ceiling) == skyflatnum) ? VisiblePlaneList::Instance()->FindPlane(frontsector->floorplane, frontsector->GetTexture(sector_t::floor), - floorlightlevel + r_actualextralight, // killough 3/16/98 + floorlightlevel + R_ActualExtraLight(foggy), // killough 3/16/98 frontsector->GetAlpha(sector_t::floor), !!(frontsector->GetFlags(sector_t::floor) & PLANEF_ADDITIVE), frontsector->planes[sector_t::floor].xform, @@ -611,7 +610,7 @@ namespace swrenderer ceilingplane = nullptr; floorplane = VisiblePlaneList::Instance()->FindPlane(frontsector->floorplane, frontsector->GetTexture(sector_t::floor), - floorlightlevel + r_actualextralight, // killough 3/16/98 + floorlightlevel + R_ActualExtraLight(foggy), // killough 3/16/98 frontsector->GetAlpha(sector_t::floor), !!(clip3d->fakeFloor->flags & FF_ADDITIVETRANS), frontsector->planes[position].xform, @@ -676,7 +675,7 @@ namespace swrenderer floorplane = nullptr; ceilingplane = VisiblePlaneList::Instance()->FindPlane(frontsector->ceilingplane, // killough 3/8/98 frontsector->GetTexture(sector_t::ceiling), - ceilinglightlevel + r_actualextralight, // killough 4/11/98 + ceilinglightlevel + R_ActualExtraLight(foggy), // killough 4/11/98 frontsector->GetAlpha(sector_t::ceiling), !!(clip3d->fakeFloor->flags & FF_ADDITIVETRANS), frontsector->planes[position].xform, @@ -710,7 +709,7 @@ namespace swrenderer // [RH] Add particles if ((unsigned int)(sub - subsectors) < (unsigned int)numsubsectors) { // Only do it for the main BSP. - int shade = LIGHT2SHADE((floorlightlevel + ceilinglightlevel) / 2 + r_actualextralight); + int shade = LIGHT2SHADE((floorlightlevel + ceilinglightlevel) / 2 + R_ActualExtraLight(foggy)); for (WORD i = ParticlesInSubsec[(unsigned int)(sub - subsectors)]; i != NO_PARTICLE; i = Particles[i].snext) { RenderParticle::Project(Particles + i, subsectors[sub - subsectors].sector, shade, FakeSide); @@ -825,7 +824,7 @@ namespace swrenderer // Well, now it will be done. sec->validcount = validcount; - int spriteshade = LIGHT2SHADE(lightlevel + r_actualextralight); + int spriteshade = LIGHT2SHADE(lightlevel + R_ActualExtraLight(foggy)); // Handle all things in sector. for (auto p = sec->touching_renderthings; p != nullptr; p = p->m_snext) diff --git a/src/swrenderer/scene/r_translucent_pass.cpp b/src/swrenderer/scene/r_translucent_pass.cpp index 9edbe972e..6c3b4500c 100644 --- a/src/swrenderer/scene/r_translucent_pass.cpp +++ b/src/swrenderer/scene/r_translucent_pass.cpp @@ -240,7 +240,7 @@ namespace swrenderer } else { // diminished light - int spriteshade = LIGHT2SHADE(sec->lightlevel + r_actualextralight); + int spriteshade = LIGHT2SHADE(sec->lightlevel + R_ActualExtraLight(foggy)); spr->Style.BaseColormap = mybasecolormap; spr->Style.ColormapNum = GETPALOOKUP(r_SpriteVisibility / MAX(MINZ, (double)spr->depth), spriteshade); } diff --git a/src/swrenderer/segments/r_drawsegment.cpp b/src/swrenderer/segments/r_drawsegment.cpp index 37356da0a..b2829b884 100644 --- a/src/swrenderer/segments/r_drawsegment.cpp +++ b/src/swrenderer/segments/r_drawsegment.cpp @@ -189,7 +189,7 @@ namespace swrenderer { lightlist_t *lit = &frontsector->e->XFloor.lightlist[i]; basecolormap = lit->extra_colormap; - wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + r_actualextralight); + wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + R_ActualExtraLight(foggy)); break; } } @@ -746,7 +746,7 @@ namespace swrenderer { lightlist_t *lit = &backsector->e->XFloor.lightlist[j]; basecolormap = lit->extra_colormap; - wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + r_actualextralight); + wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + R_ActualExtraLight(foggy)); break; } } @@ -759,7 +759,7 @@ namespace swrenderer { lightlist_t *lit = &frontsector->e->XFloor.lightlist[j]; basecolormap = lit->extra_colormap; - wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + r_actualextralight); + wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + R_ActualExtraLight(foggy)); break; } } @@ -920,7 +920,7 @@ namespace swrenderer { lightlist_t *lit = &backsector->e->XFloor.lightlist[j]; basecolormap = lit->extra_colormap; - wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + r_actualextralight); + wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + R_ActualExtraLight(foggy)); break; } } @@ -933,7 +933,7 @@ namespace swrenderer { lightlist_t *lit = &frontsector->e->XFloor.lightlist[j]; basecolormap = lit->extra_colormap; - wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + r_actualextralight); + wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + R_ActualExtraLight(foggy)); break; } } diff --git a/src/swrenderer/things/r_playersprite.cpp b/src/swrenderer/things/r_playersprite.cpp index 1efc780f0..72a383b58 100644 --- a/src/swrenderer/things/r_playersprite.cpp +++ b/src/swrenderer/things/r_playersprite.cpp @@ -137,10 +137,9 @@ namespace swrenderer // [RH] set foggy flag foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); - r_actualextralight = foggy ? 0 : extralight << 4; // get light level - lightnum = ((floorlight + ceilinglight) >> 1) + r_actualextralight; + lightnum = ((floorlight + ceilinglight) >> 1) + R_ActualExtraLight(foggy); int spriteshade = LIGHT2SHADE(lightnum) - 24 * FRACUNIT; if (camera->player != NULL) diff --git a/src/swrenderer/things/r_wallsprite.cpp b/src/swrenderer/things/r_wallsprite.cpp index e55b0fcc5..b340897e0 100644 --- a/src/swrenderer/things/r_wallsprite.cpp +++ b/src/swrenderer/things/r_wallsprite.cpp @@ -174,7 +174,7 @@ namespace swrenderer rereadcolormap = false; } - int shade = LIGHT2SHADE(spr->sector->lightlevel + r_actualextralight); + int shade = LIGHT2SHADE(spr->sector->lightlevel + R_ActualExtraLight(foggy)); double GlobVis = r_WallVisibility; float lightleft = float(GlobVis / spr->wallc.sz1); float lightstep = float((GlobVis / spr->wallc.sz2 - lightleft) / (spr->wallc.sx2 - spr->wallc.sx1));