mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 15:22:15 +00:00
Add R_DrawFogBoundaryLine and move R_DrawFogBoundary to a source file closer to its correct location
This commit is contained in:
parent
f1cd91922b
commit
325fa20a02
4 changed files with 114 additions and 117 deletions
|
@ -57,12 +57,6 @@ CVAR(Bool, r_dynlights, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
|
|||
|
||||
namespace swrenderer
|
||||
{
|
||||
// Needed by R_DrawFogBoundary (which probably shouldn't be part of this file)
|
||||
extern "C" short spanend[MAXHEIGHT];
|
||||
extern float rw_light;
|
||||
extern float rw_lightstep;
|
||||
extern int wallshade;
|
||||
|
||||
double dc_texturemid;
|
||||
FLightNode *dc_light_list;
|
||||
visplane_light *ds_light_list;
|
||||
|
@ -909,116 +903,11 @@ namespace swrenderer
|
|||
DrawerCommandQueue::QueueCommand<DrawColoredSpanPalCommand>(y, x1, x2);
|
||||
}
|
||||
|
||||
void R_DrawFogBoundarySection(int y, int y2, int x1)
|
||||
void R_DrawFogBoundaryLine(int y, int x1, int x2)
|
||||
{
|
||||
for (; y < y2; ++y)
|
||||
{
|
||||
int x2 = spanend[y];
|
||||
if (r_swtruecolor)
|
||||
DrawerCommandQueue::QueueCommand<DrawFogBoundaryLineRGBACommand>(y, x1, x2);
|
||||
else
|
||||
DrawerCommandQueue::QueueCommand<DrawFogBoundaryLinePalCommand>(y, x1, x2);
|
||||
}
|
||||
}
|
||||
|
||||
void R_DrawFogBoundary(int x1, int x2, short *uclip, short *dclip)
|
||||
{
|
||||
// This is essentially the same as R_MapVisPlane but with an extra step
|
||||
// to create new horizontal spans whenever the light changes enough that
|
||||
// we need to use a new colormap.
|
||||
|
||||
double lightstep = rw_lightstep;
|
||||
double light = rw_light + rw_lightstep*(x2 - x1 - 1);
|
||||
int x = x2 - 1;
|
||||
int t2 = uclip[x];
|
||||
int b2 = dclip[x];
|
||||
int rcolormap = GETPALOOKUP(light, wallshade);
|
||||
int lcolormap;
|
||||
uint8_t *basecolormapdata = basecolormap->Maps;
|
||||
|
||||
if (b2 > t2)
|
||||
{
|
||||
fillshort(spanend + t2, b2 - t2, x);
|
||||
}
|
||||
|
||||
R_SetColorMapLight(basecolormap, (float)light, wallshade);
|
||||
|
||||
uint8_t *fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT);
|
||||
|
||||
for (--x; x >= x1; --x)
|
||||
{
|
||||
int t1 = uclip[x];
|
||||
int b1 = dclip[x];
|
||||
const int xr = x + 1;
|
||||
int stop;
|
||||
|
||||
light -= rw_lightstep;
|
||||
lcolormap = GETPALOOKUP(light, wallshade);
|
||||
if (lcolormap != rcolormap)
|
||||
{
|
||||
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);
|
||||
}
|
||||
if (t1 < t2) t2 = t1;
|
||||
if (b1 > b2) b2 = b1;
|
||||
if (t2 < b2)
|
||||
{
|
||||
fillshort(spanend + t2, b2 - t2, x);
|
||||
}
|
||||
rcolormap = lcolormap;
|
||||
R_SetColorMapLight(basecolormap, (float)light, wallshade);
|
||||
fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fake_dc_colormap != basecolormapdata)
|
||||
{
|
||||
stop = MIN(t1, b2);
|
||||
while (t2 < stop)
|
||||
{
|
||||
int y = t2++;
|
||||
if (r_swtruecolor)
|
||||
DrawerCommandQueue::QueueCommand<DrawFogBoundaryLineRGBACommand>(y, xr, spanend[y]);
|
||||
else
|
||||
DrawerCommandQueue::QueueCommand<DrawFogBoundaryLinePalCommand>(y, xr, spanend[y]);
|
||||
}
|
||||
stop = MAX(b1, t2);
|
||||
while (b2 > stop)
|
||||
{
|
||||
int y = --b2;
|
||||
if (r_swtruecolor)
|
||||
DrawerCommandQueue::QueueCommand<DrawFogBoundaryLineRGBACommand>(y, xr, spanend[y]);
|
||||
else
|
||||
DrawerCommandQueue::QueueCommand<DrawFogBoundaryLinePalCommand>(y, xr, spanend[y]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
t2 = MAX(t2, MIN(t1, b2));
|
||||
b2 = MIN(b2, MAX(b1, t2));
|
||||
}
|
||||
|
||||
stop = MIN(t2, b1);
|
||||
while (t1 < stop)
|
||||
{
|
||||
spanend[t1++] = x;
|
||||
}
|
||||
stop = MAX(b2, t2);
|
||||
while (b1 > stop)
|
||||
{
|
||||
spanend[--b1] = x;
|
||||
}
|
||||
}
|
||||
|
||||
t2 = uclip[x];
|
||||
b2 = dclip[x];
|
||||
}
|
||||
if (t2 < b2 && rcolormap != 0)
|
||||
{
|
||||
R_DrawFogBoundarySection(t2, b2, x1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -160,7 +160,7 @@ namespace swrenderer
|
|||
void R_FillSpan();
|
||||
void R_DrawTiltedSpan(int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy);
|
||||
void R_DrawColoredSpan(int y, int x1, int x2);
|
||||
void R_DrawFogBoundary(int x1, int x2, short *uclip, short *dclip);
|
||||
void R_DrawFogBoundaryLine(int y, int x1, int x2);
|
||||
void R_FillSpan();
|
||||
|
||||
void R_DrawWallColumn();
|
||||
|
|
|
@ -75,6 +75,8 @@ namespace swrenderer
|
|||
{
|
||||
using namespace drawerargs;
|
||||
|
||||
extern int wallshade;
|
||||
|
||||
extern subsector_t *InSubsector;
|
||||
|
||||
static void R_DrawSkyStriped (visplane_t *pl);
|
||||
|
@ -341,6 +343,110 @@ void R_MapColoredPlane(int y, int x1)
|
|||
R_DrawColoredSpan(y, x1, spanend[y]);
|
||||
}
|
||||
|
||||
void R_DrawFogBoundarySection(int y, int y2, int x1)
|
||||
{
|
||||
for (; y < y2; ++y)
|
||||
{
|
||||
R_DrawFogBoundaryLine(y, x1, spanend[y]);
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
||||
void R_DrawFogBoundary(int x1, int x2, short *uclip, short *dclip)
|
||||
{
|
||||
// This is essentially the same as R_MapVisPlane but with an extra step
|
||||
// to create new horizontal spans whenever the light changes enough that
|
||||
// we need to use a new colormap.
|
||||
|
||||
double lightstep = rw_lightstep;
|
||||
double light = rw_light + rw_lightstep*(x2 - x1 - 1);
|
||||
int x = x2 - 1;
|
||||
int t2 = uclip[x];
|
||||
int b2 = dclip[x];
|
||||
int rcolormap = GETPALOOKUP(light, wallshade);
|
||||
int lcolormap;
|
||||
uint8_t *basecolormapdata = basecolormap->Maps;
|
||||
|
||||
if (b2 > t2)
|
||||
{
|
||||
fillshort(spanend + t2, b2 - t2, x);
|
||||
}
|
||||
|
||||
R_SetColorMapLight(basecolormap, (float)light, wallshade);
|
||||
|
||||
uint8_t *fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT);
|
||||
|
||||
for (--x; x >= x1; --x)
|
||||
{
|
||||
int t1 = uclip[x];
|
||||
int b1 = dclip[x];
|
||||
const int xr = x + 1;
|
||||
int stop;
|
||||
|
||||
light -= rw_lightstep;
|
||||
lcolormap = GETPALOOKUP(light, wallshade);
|
||||
if (lcolormap != rcolormap)
|
||||
{
|
||||
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);
|
||||
}
|
||||
if (t1 < t2) t2 = t1;
|
||||
if (b1 > b2) b2 = b1;
|
||||
if (t2 < b2)
|
||||
{
|
||||
fillshort(spanend + t2, b2 - t2, x);
|
||||
}
|
||||
rcolormap = lcolormap;
|
||||
R_SetColorMapLight(basecolormap, (float)light, wallshade);
|
||||
fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fake_dc_colormap != basecolormapdata)
|
||||
{
|
||||
stop = MIN(t1, b2);
|
||||
while (t2 < stop)
|
||||
{
|
||||
int y = t2++;
|
||||
R_DrawFogBoundaryLine(y, xr, spanend[y]);
|
||||
}
|
||||
stop = MAX(b1, t2);
|
||||
while (b2 > stop)
|
||||
{
|
||||
int y = --b2;
|
||||
R_DrawFogBoundaryLine(y, xr, spanend[y]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
t2 = MAX(t2, MIN(t1, b2));
|
||||
b2 = MIN(b2, MAX(b1, t2));
|
||||
}
|
||||
|
||||
stop = MIN(t2, b1);
|
||||
while (t1 < stop)
|
||||
{
|
||||
spanend[t1++] = x;
|
||||
}
|
||||
stop = MAX(b2, t2);
|
||||
while (b1 > stop)
|
||||
{
|
||||
spanend[--b1] = x;
|
||||
}
|
||||
}
|
||||
|
||||
t2 = uclip[x];
|
||||
b2 = dclip[x];
|
||||
}
|
||||
if (t2 < b2 && rcolormap != 0)
|
||||
{
|
||||
R_DrawFogBoundarySection(t2, b2, x1);
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
||||
namespace
|
||||
|
|
|
@ -110,6 +110,8 @@ void R_MapVisPlane (visplane_t *pl, void (*mapfunc)(int y, int x1));
|
|||
void R_MapTiltedPlane(int y, int x1);
|
||||
void R_MapColoredPlane(int y, int x1);
|
||||
|
||||
void R_DrawFogBoundary(int x1, int x2, short *uclip, short *dclip);
|
||||
|
||||
visplane_t *R_FindPlane
|
||||
( const secplane_t &height,
|
||||
FTextureID picnum,
|
||||
|
|
Loading…
Reference in a new issue