From fc29958dc727c8628bf135f08bf941364f045ecf Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Wed, 11 Jan 2017 21:33:28 +0100 Subject: [PATCH] Convert r_fogboundary to a class --- src/swrenderer/line/r_fogboundary.cpp | 15 ++++++--------- src/swrenderer/line/r_fogboundary.h | 13 +++++++++++-- src/swrenderer/segments/r_drawsegment.cpp | 2 +- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/swrenderer/line/r_fogboundary.cpp b/src/swrenderer/line/r_fogboundary.cpp index edaa942655..ca1822a2c1 100644 --- a/src/swrenderer/line/r_fogboundary.cpp +++ b/src/swrenderer/line/r_fogboundary.cpp @@ -45,12 +45,7 @@ namespace swrenderer { - namespace - { - short spanend[MAXHEIGHT]; - } - - void R_DrawFogBoundary(int x1, int x2, short *uclip, short *dclip, int wallshade, float lightleft, float lightstep) + void RenderFogBoundary::Render(int x1, int x2, short *uclip, short *dclip, int wallshade, float lightleft, float lightstep) { // This is essentially the same as R_MapVisPlane but with an extra step // to create new horizontal spans whenever the light changes enough that @@ -87,7 +82,7 @@ namespace swrenderer if (t2 < b2 && rcolormap != 0) { // Colormap 0 is always the identity map, so rendering it is // just a waste of time. - R_DrawFogBoundarySection(t2, b2, xr); + RenderSection(t2, b2, xr); } if (t1 < t2) t2 = t1; if (b1 > b2) b2 = b1; @@ -139,15 +134,17 @@ namespace swrenderer } if (t2 < b2 && rcolormap != 0) { - R_DrawFogBoundarySection(t2, b2, x1); + RenderSection(t2, b2, x1); } } - void R_DrawFogBoundarySection(int y, int y2, int x1) + void RenderFogBoundary::RenderSection(int y, int y2, int x1) { for (; y < y2; ++y) { R_Drawers()->DrawFogBoundaryLine(y, x1, spanend[y]); } } + + short RenderFogBoundary::spanend[MAXHEIGHT]; } diff --git a/src/swrenderer/line/r_fogboundary.h b/src/swrenderer/line/r_fogboundary.h index bb7d267241..de48738a09 100644 --- a/src/swrenderer/line/r_fogboundary.h +++ b/src/swrenderer/line/r_fogboundary.h @@ -15,6 +15,15 @@ namespace swrenderer { - void R_DrawFogBoundary(int x1, int x2, short *uclip, short *dclip, int wallshade, float lightleft, float lightstep); - void R_DrawFogBoundarySection(int y, int y2, int x1); + class RenderFogBoundary + { + public: + static void Render(int x1, int x2, short *uclip, short *dclip, int wallshade, float lightleft, float lightstep); + + private: + static void RenderSection(int y, int y2, int x1); + + static short spanend[MAXHEIGHT]; + }; + } diff --git a/src/swrenderer/segments/r_drawsegment.cpp b/src/swrenderer/segments/r_drawsegment.cpp index 269154b9e3..99ad33cefe 100644 --- a/src/swrenderer/segments/r_drawsegment.cpp +++ b/src/swrenderer/segments/r_drawsegment.cpp @@ -201,7 +201,7 @@ namespace swrenderer // [RH] Draw fog partition if (ds->bFogBoundary) { - R_DrawFogBoundary(x1, x2, mceilingclip, mfloorclip, wallshade, rw_light, rw_lightstep); + RenderFogBoundary::Render(x1, x2, mceilingclip, mfloorclip, wallshade, rw_light, rw_lightstep); if (ds->maskedtexturecol == -1) { goto clearfog;