Convert r_fogboundary to a class

This commit is contained in:
Magnus Norddahl 2017-01-11 21:33:28 +01:00
parent 3f8e5d26b8
commit fc29958dc7
3 changed files with 18 additions and 12 deletions

View file

@ -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];
}

View file

@ -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];
};
}

View file

@ -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;