Removed dc_texturemid

This commit is contained in:
Magnus Norddahl 2017-01-12 22:52:17 +01:00
parent bd8d2f501f
commit 9723078121
12 changed files with 90 additions and 95 deletions

View file

@ -56,8 +56,6 @@ CVAR(Bool, r_dynlights, 1, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
namespace swrenderer
{
double dc_texturemid;
int ylookup[MAXHEIGHT];
uint8_t shadetables[NUMCOLORMAPS * 16 * 256];
FDynamicColormap ShadeFakeColormap[16];

View file

@ -35,8 +35,6 @@ namespace swrenderer
bool simple_shade;
};
extern double dc_texturemid;
namespace drawerargs
{
extern int dc_pitch;

View file

@ -1059,7 +1059,6 @@ namespace swrenderer
{ // one sided line
if (midtexture->UseType != FTexture::TEX_Null && viewactive)
{
dc_texturemid = rw_midtexturemid;
rw_pic = midtexture;
xscale = rw_pic->Scale.X * rw_midtexturescalex;
yscale = rw_pic->Scale.Y * rw_midtexturescaley;
@ -1080,7 +1079,7 @@ namespace swrenderer
{
rw_offset = -rw_offset;
}
R_DrawWallSegment(frontsector, curline, WallC, rw_pic, x1, x2, walltop, wallbottom, swall, lwall, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_frontfz1, rw_frontfz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy, basecolormap);
R_DrawWallSegment(frontsector, curline, WallC, rw_pic, x1, x2, walltop, wallbottom, rw_midtexturemid, swall, lwall, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_frontfz1, rw_frontfz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy, basecolormap);
}
fillshort(ceilingclip + x1, x2 - x1, viewheight);
fillshort(floorclip + x1, x2 - x1, 0xffff);
@ -1095,7 +1094,6 @@ namespace swrenderer
}
if (viewactive)
{
dc_texturemid = rw_toptexturemid;
rw_pic = toptexture;
xscale = rw_pic->Scale.X * rw_toptexturescalex;
yscale = rw_pic->Scale.Y * rw_toptexturescaley;
@ -1116,7 +1114,7 @@ namespace swrenderer
{
rw_offset = -rw_offset;
}
R_DrawWallSegment(frontsector, curline, WallC, rw_pic, x1, x2, walltop, wallupper, swall, lwall, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_backcz1, rw_backcz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy, basecolormap);
R_DrawWallSegment(frontsector, curline, WallC, rw_pic, x1, x2, walltop, wallupper, rw_toptexturemid, swall, lwall, yscale, MAX(rw_frontcz1, rw_frontcz2), MIN(rw_backcz1, rw_backcz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy, basecolormap);
}
memcpy(ceilingclip + x1, wallupper + x1, (x2 - x1) * sizeof(short));
}
@ -1134,7 +1132,6 @@ namespace swrenderer
}
if (viewactive)
{
dc_texturemid = rw_bottomtexturemid;
rw_pic = bottomtexture;
xscale = rw_pic->Scale.X * rw_bottomtexturescalex;
yscale = rw_pic->Scale.Y * rw_bottomtexturescaley;
@ -1155,7 +1152,7 @@ namespace swrenderer
{
rw_offset = -rw_offset;
}
R_DrawWallSegment(frontsector, curline, WallC, rw_pic, x1, x2, walllower, wallbottom, swall, lwall, yscale, MAX(rw_backfz1, rw_backfz2), MIN(rw_frontfz1, rw_frontfz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy, basecolormap);
R_DrawWallSegment(frontsector, curline, WallC, rw_pic, x1, x2, walllower, wallbottom, rw_bottomtexturemid, swall, lwall, yscale, MAX(rw_backfz1, rw_backfz2), MIN(rw_frontfz1, rw_frontfz2), false, wallshade, rw_offset, rw_light, rw_lightstep, light_list, foggy, basecolormap);
}
memcpy(floorclip + x1, walllower + x1, (x2 - x1) * sizeof(short));
}

View file

@ -76,7 +76,7 @@ namespace swrenderer
return tex->GetColumn(col, nullptr);
}
WallSampler::WallSampler(int y1, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x))
WallSampler::WallSampler(int y1, double texturemid, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x))
{
xoffset += FLOAT2FIXED(xmagnitude * 0.5);
@ -92,7 +92,7 @@ namespace swrenderer
// Find start uv in [0-base_height[ range.
// Not using xs_ToFixed because it rounds the result and we need something that always rounds down to stay within the range.
double uv_stepd = swal * yrepeat;
double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / height;
double v = (texturemid + uv_stepd * (y1 - CenterY + 0.5)) / height;
v = v - floor(v);
v *= height;
v *= (1 << uv_fracbits);
@ -117,7 +117,7 @@ namespace swrenderer
{
// Normalize to 0-1 range:
double uv_stepd = swal * yrepeat;
double v = (dc_texturemid + uv_stepd * (y1 - CenterY + 0.5)) / texture->GetHeight();
double v = (texturemid + uv_stepd * (y1 - CenterY + 0.5)) / texture->GetHeight();
v = v - floor(v);
double v_step = uv_stepd / texture->GetHeight();
@ -337,7 +337,7 @@ namespace swrenderer
static void ProcessWallWorker(
const FWallCoords &WallC,
int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap,
int x1, int x2, short *uwal, short *dwal, double texturemid, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap,
FLightNode *light_list,
const BYTE *(*getcol)(FTexture *tex, int x), DrawerFunc drawcolumn)
{
@ -350,7 +350,7 @@ namespace swrenderer
{ // Hack for one pixel tall textures
fracbits = 0;
yrepeat = 0;
dc_texturemid = 0;
texturemid = 0;
}
dc_wall_fracbits = r_swtruecolor ? FRACBITS : fracbits;
@ -394,45 +394,45 @@ namespace swrenderer
if (x + 1 < x2) xmagnitude = fabs(FIXED2DBL(lwal[x + 1]) - FIXED2DBL(lwal[x]));
WallSampler sampler(y1, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic, getcol);
WallSampler sampler(y1, texturemid, swal[x], yrepeat, lwal[x] + xoffset, xmagnitude, rw_pic, getcol);
Draw1Column(WallC, x, y1, y2, sampler, light_list, drawcolumn);
}
NetUpdate();
}
static void ProcessNormalWall(const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap, FLightNode *light_list, const BYTE *(*getcol)(FTexture *tex, int x) = R_GetColumn)
static void ProcessNormalWall(const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, double texturemid, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap, FLightNode *light_list, const BYTE *(*getcol)(FTexture *tex, int x) = R_GetColumn)
{
ProcessWallWorker(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list, getcol, &SWPixelFormatDrawers::DrawWallColumn);
ProcessWallWorker(WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list, getcol, &SWPixelFormatDrawers::DrawWallColumn);
}
static void ProcessMaskedWall(const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap, FLightNode *light_list, const BYTE *(*getcol)(FTexture *tex, int x) = R_GetColumn)
static void ProcessMaskedWall(const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, double texturemid, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap, FLightNode *light_list, const BYTE *(*getcol)(FTexture *tex, int x) = R_GetColumn)
{
if (!rw_pic->bMasked) // Textures that aren't masked can use the faster ProcessNormalWall.
{
ProcessNormalWall(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list, getcol);
ProcessNormalWall(WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list, getcol);
}
else
{
ProcessWallWorker(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list, getcol, &SWPixelFormatDrawers::DrawWallMaskedColumn);
ProcessWallWorker(WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list, getcol, &SWPixelFormatDrawers::DrawWallMaskedColumn);
}
}
static void ProcessTranslucentWall(const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap, FLightNode *light_list, const BYTE *(*getcol)(FTexture *tex, int x) = R_GetColumn)
static void ProcessTranslucentWall(const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, double texturemid, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap, FLightNode *light_list, const BYTE *(*getcol)(FTexture *tex, int x) = R_GetColumn)
{
DrawerFunc drawcol1 = R_GetTransMaskDrawer();
if (drawcol1 == nullptr)
{
// The current translucency is unsupported, so draw with regular ProcessMaskedWall instead.
ProcessMaskedWall(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list, getcol);
ProcessMaskedWall(WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list, getcol);
}
else
{
ProcessWallWorker(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list, getcol, drawcol1);
ProcessWallWorker(WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list, getcol, drawcol1);
}
}
static void ProcessStripedWall(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, bool foggy, FDynamicColormap *basecolormap, FLightNode *light_list)
static void ProcessStripedWall(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, double texturemid, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, bool foggy, FDynamicColormap *basecolormap, FLightNode *light_list)
{
short most1[MAXWIDTH], most2[MAXWIDTH], most3[MAXWIDTH];
short *up, *down;
@ -455,7 +455,7 @@ namespace swrenderer
{
down[j] = clamp(most3[j], up[j], dwal[j]);
}
ProcessNormalWall(WallC, x1, x2, up, down, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list);
ProcessNormalWall(WallC, x1, x2, up, down, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list);
up = down;
down = (down == most1) ? most2 : most1;
}
@ -465,31 +465,31 @@ namespace swrenderer
wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != NULL) + R_ActualExtraLight(foggy));
}
ProcessNormalWall(WallC, x1, x2, up, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list);
ProcessNormalWall(WallC, x1, x2, up, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list);
}
static void ProcessWall(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, bool mask, bool foggy, FDynamicColormap *basecolormap, FLightNode *light_list)
static void ProcessWall(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, double texturemid, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, bool mask, bool foggy, FDynamicColormap *basecolormap, FLightNode *light_list)
{
if (mask)
{
if (colfunc == basecolfunc)
{
ProcessMaskedWall(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list);
ProcessMaskedWall(WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list);
}
else
{
ProcessTranslucentWall(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list);
ProcessTranslucentWall(WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list);
}
}
else
{
if (fixedcolormap != NULL || fixedlightlev >= 0 || !(frontsector->e && frontsector->e->XFloor.lightlist.Size()))
{
ProcessNormalWall(WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list);
ProcessNormalWall(WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, light_list);
}
else
{
ProcessStripedWall(frontsector, curline, WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, foggy, basecolormap, light_list);
ProcessStripedWall(frontsector, curline, WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, foggy, basecolormap, light_list);
}
}
}
@ -505,7 +505,7 @@ namespace swrenderer
//
//=============================================================================
static void ProcessWallNP2(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, double top, double bot, int wallshade, fixed_t xoffset, float light, float lightstep, bool mask, bool foggy, FDynamicColormap *basecolormap, FLightNode *light_list)
static void ProcessWallNP2(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, int x1, int x2, short *uwal, short *dwal, double texturemid, float *swal, fixed_t *lwal, double yrepeat, double top, double bot, int wallshade, fixed_t xoffset, float light, float lightstep, bool mask, bool foggy, FDynamicColormap *basecolormap, FLightNode *light_list)
{
short most1[MAXWIDTH], most2[MAXWIDTH], most3[MAXWIDTH];
short *up, *down;
@ -515,14 +515,14 @@ namespace swrenderer
if (yrepeat >= 0)
{ // normal orientation: draw strips from top to bottom
partition = top - fmod(top - dc_texturemid / yrepeat - ViewPos.Z, scaledtexheight);
partition = top - fmod(top - texturemid / yrepeat - ViewPos.Z, scaledtexheight);
if (partition == top)
{
partition -= scaledtexheight;
}
up = uwal;
down = most1;
dc_texturemid = (partition - ViewPos.Z) * yrepeat + texheight;
texturemid = (partition - ViewPos.Z) * yrepeat + texheight;
while (partition > bot)
{
int j = R_CreateWallSegmentY(most3, partition - ViewPos.Z, &WallC);
@ -532,21 +532,21 @@ namespace swrenderer
{
down[j] = clamp(most3[j], up[j], dwal[j]);
}
ProcessWall(frontsector, curline, WallC, x1, x2, up, down, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, mask, foggy, basecolormap, light_list);
ProcessWall(frontsector, curline, WallC, x1, x2, up, down, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, mask, foggy, basecolormap, light_list);
up = down;
down = (down == most1) ? most2 : most1;
}
partition -= scaledtexheight;
dc_texturemid -= texheight;
texturemid -= texheight;
}
ProcessWall(frontsector, curline, WallC, x1, x2, up, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, mask, foggy, basecolormap, light_list);
ProcessWall(frontsector, curline, WallC, x1, x2, up, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, mask, foggy, basecolormap, light_list);
}
else
{ // upside down: draw strips from bottom to top
partition = bot - fmod(bot - dc_texturemid / yrepeat - ViewPos.Z, scaledtexheight);
partition = bot - fmod(bot - texturemid / yrepeat - ViewPos.Z, scaledtexheight);
up = most1;
down = dwal;
dc_texturemid = (partition - ViewPos.Z) * yrepeat + texheight;
texturemid = (partition - ViewPos.Z) * yrepeat + texheight;
while (partition < top)
{
int j = R_CreateWallSegmentY(most3, partition - ViewPos.Z, &WallC);
@ -556,18 +556,18 @@ namespace swrenderer
{
up[j] = clamp(most3[j], uwal[j], down[j]);
}
ProcessWall(frontsector, curline, WallC, x1, x2, up, down, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, mask, foggy, basecolormap, light_list);
ProcessWall(frontsector, curline, WallC, x1, x2, up, down, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, mask, foggy, basecolormap, light_list);
down = up;
up = (up == most1) ? most2 : most1;
}
partition -= scaledtexheight;
dc_texturemid -= texheight;
texturemid -= texheight;
}
ProcessWall(frontsector, curline, WallC, x1, x2, uwal, down, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, mask, foggy, basecolormap, light_list);
ProcessWall(frontsector, curline, WallC, x1, x2, uwal, down, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, mask, foggy, basecolormap, light_list);
}
}
void R_DrawDrawSeg(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *pic, drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, bool foggy, FDynamicColormap *basecolormap)
void R_DrawDrawSeg(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *pic, drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, double texturemid, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, bool foggy, FDynamicColormap *basecolormap)
{
rw_pic = pic;
if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits)
@ -587,32 +587,32 @@ namespace swrenderer
{
bot = MAX(bot, clip3d->sclipBottom);
}
ProcessWallNP2(frontsector, curline, WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, top, bot, wallshade, xoffset, light, lightstep, true, foggy, basecolormap, nullptr);
ProcessWallNP2(frontsector, curline, WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, top, bot, wallshade, xoffset, light, lightstep, true, foggy, basecolormap, nullptr);
}
else
{
ProcessWall(frontsector, curline, WallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, true, foggy, basecolormap, nullptr);
ProcessWall(frontsector, curline, WallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, true, foggy, basecolormap, nullptr);
}
}
void R_DrawWallSegment(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *pic, int x1, int x2, short *walltop, short *wallbottom, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask, int wallshade, fixed_t xoffset, float light, float lightstep, FLightNode *light_list, bool foggy, FDynamicColormap *basecolormap)
void R_DrawWallSegment(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *pic, int x1, int x2, short *walltop, short *wallbottom, double texturemid, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask, int wallshade, fixed_t xoffset, float light, float lightstep, FLightNode *light_list, bool foggy, FDynamicColormap *basecolormap)
{
rw_pic = pic;
if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits)
{
ProcessWallNP2(frontsector, curline, WallC, x1, x2, walltop, wallbottom, swall, lwall, yscale, top, bottom, wallshade, xoffset, light, lightstep, false, foggy, basecolormap, light_list);
ProcessWallNP2(frontsector, curline, WallC, x1, x2, walltop, wallbottom, texturemid, swall, lwall, yscale, top, bottom, wallshade, xoffset, light, lightstep, false, foggy, basecolormap, light_list);
}
else
{
ProcessWall(frontsector, curline, WallC, x1, x2, walltop, wallbottom, swall, lwall, yscale, wallshade, xoffset, light, lightstep, false, foggy, basecolormap, light_list);
ProcessWall(frontsector, curline, WallC, x1, x2, walltop, wallbottom, texturemid, swall, lwall, yscale, wallshade, xoffset, light, lightstep, false, foggy, basecolormap, light_list);
}
}
void R_DrawSkySegment(FTexture *pic, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap, const uint8_t *(*getcol)(FTexture *tex, int x))
void R_DrawSkySegment(FTexture *pic, int x1, int x2, short *uwal, short *dwal, double texturemid, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap, const uint8_t *(*getcol)(FTexture *tex, int x))
{
rw_pic = pic;
FWallCoords wallC; // Not used. To do: don't use r_walldraw to draw the sky!!
ProcessNormalWall(wallC, x1, x2, uwal, dwal, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, nullptr, getcol);
ProcessNormalWall(wallC, x1, x2, uwal, dwal, texturemid, swal, lwal, yrepeat, wallshade, xoffset, light, lightstep, basecolormap, nullptr, getcol);
}
}

View file

@ -25,7 +25,7 @@ namespace swrenderer
struct WallSampler
{
WallSampler() { }
WallSampler(int y1, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x));
WallSampler(int y1, double texturemid, float swal, double yrepeat, fixed_t xoffset, double xmagnitude, FTexture *texture, const BYTE*(*getcol)(FTexture *texture, int x));
uint32_t uv_pos;
uint32_t uv_step;
@ -37,7 +37,7 @@ namespace swrenderer
uint32_t height;
};
void R_DrawWallSegment(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *rw_pic, int x1, int x2, short *walltop, short *wallbottom, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask, int wallshade, fixed_t xoffset, float light, float lightstep, FLightNode *light_list, bool foggy, FDynamicColormap *basecolormap);
void R_DrawSkySegment(FTexture *rw_pic, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap, const uint8_t *(*getcol)(FTexture *tex, int col));
void R_DrawDrawSeg(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *rw_pic, drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, bool foggy, FDynamicColormap *basecolormap);
void R_DrawWallSegment(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *rw_pic, int x1, int x2, short *walltop, short *wallbottom, double texturemid, float *swall, fixed_t *lwall, double yscale, double top, double bottom, bool mask, int wallshade, fixed_t xoffset, float light, float lightstep, FLightNode *light_list, bool foggy, FDynamicColormap *basecolormap);
void R_DrawSkySegment(FTexture *rw_pic, int x1, int x2, short *uwal, short *dwal, double texturemid, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, FDynamicColormap *basecolormap, const uint8_t *(*getcol)(FTexture *tex, int col));
void R_DrawDrawSeg(sector_t *frontsector, seg_t *curline, const FWallCoords &WallC, FTexture *rw_pic, drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, double texturemid, float *swal, fixed_t *lwal, double yrepeat, int wallshade, fixed_t xoffset, float light, float lightstep, bool foggy, FDynamicColormap *basecolormap);
}

View file

@ -436,7 +436,7 @@ namespace swrenderer
}
frontyScale = frontskytex->Scale.Y;
dc_texturemid = skymid * frontyScale;
double texturemid = skymid * frontyScale;
if (1 << frontskytex->HeightBits == frontskytex->GetHeight())
{ // The texture tiles nicely
@ -445,7 +445,7 @@ namespace swrenderer
lastskycol[x] = 0xffffffff;
lastskycol_bgra[x] = 0xffffffff;
}
R_DrawSkySegment(frontskytex, pl->left, pl->right, (short *)pl->top, (short *)pl->bottom, swall, lwall,
R_DrawSkySegment(frontskytex, pl->left, pl->right, (short *)pl->top, (short *)pl->bottom, texturemid, swall, lwall,
frontyScale, 0, 0, 0.0f, 0.0f, nullptr, backskytex == nullptr ? RenderSkyPlane::GetOneSkyColumn : RenderSkyPlane::GetTwoSkyColumns);
}
else
@ -469,7 +469,7 @@ namespace swrenderer
if (topfrac < 0) topfrac += frontskytex->GetHeight();
yl = 0;
yh = short((frontskytex->GetHeight() - topfrac) * frontyScale);
dc_texturemid = topfrac - iscale * (1 - CenterY);
double texturemid = topfrac - iscale * (1 - CenterY);
while (yl < viewheight)
{
@ -483,10 +483,10 @@ namespace swrenderer
lastskycol[x] = 0xffffffff;
lastskycol_bgra[x] = 0xffffffff;
}
R_DrawSkySegment(frontskytex, pl->left, pl->right, top, bot, swall, lwall, frontskytex->Scale.Y, 0, 0, 0.0f, 0.0f, nullptr, backskytex == nullptr ? RenderSkyPlane::GetOneSkyColumn : RenderSkyPlane::GetTwoSkyColumns);
R_DrawSkySegment(frontskytex, pl->left, pl->right, top, bot, texturemid, swall, lwall, frontskytex->Scale.Y, 0, 0, 0.0f, 0.0f, nullptr, backskytex == nullptr ? RenderSkyPlane::GetOneSkyColumn : RenderSkyPlane::GetTwoSkyColumns);
yl = yh;
yh += drawheight;
dc_texturemid = iscale * (centery - yl - 1);
texturemid = iscale * (centery - yl - 1);
}
}

View file

@ -232,13 +232,15 @@ namespace swrenderer
{
texheight = texheight / texheightscale;
}
double texturemid;
if (curline->linedef->flags & ML_DONTPEGBOTTOM)
{
dc_texturemid = MAX(frontsector->GetPlaneTexZ(sector_t::floor), backsector->GetPlaneTexZ(sector_t::floor)) + texheight;
texturemid = MAX(frontsector->GetPlaneTexZ(sector_t::floor), backsector->GetPlaneTexZ(sector_t::floor)) + texheight;
}
else
{
dc_texturemid = MIN(frontsector->GetPlaneTexZ(sector_t::ceiling), backsector->GetPlaneTexZ(sector_t::ceiling));
texturemid = MIN(frontsector->GetPlaneTexZ(sector_t::ceiling), backsector->GetPlaneTexZ(sector_t::ceiling));
}
rowoffset = curline->sidedef->GetTextureYOffset(side_t::mid);
@ -257,21 +259,21 @@ namespace swrenderer
{
// rowoffset is added before the multiply so that the masked texture will
// still be positioned in world units rather than texels.
dc_texturemid += rowoffset - ViewPos.Z;
textop = dc_texturemid;
dc_texturemid *= MaskedScaleY;
texturemid += rowoffset - ViewPos.Z;
textop = texturemid;
texturemid *= MaskedScaleY;
}
else
{
// rowoffset is added outside the multiply so that it positions the texture
// by texels instead of world units.
textop = dc_texturemid + rowoffset / MaskedScaleY - ViewPos.Z;
dc_texturemid = (dc_texturemid - ViewPos.Z) * MaskedScaleY + rowoffset;
textop = texturemid + rowoffset / MaskedScaleY - ViewPos.Z;
texturemid = (texturemid - ViewPos.Z) * MaskedScaleY + rowoffset;
}
if (sprflipvert)
{
MaskedScaleY = -MaskedScaleY;
dc_texturemid -= tex->GetHeight() << FRACBITS;
texturemid -= tex->GetHeight() << FRACBITS;
}
// [RH] Don't bother drawing segs that are completely offscreen
@ -356,9 +358,9 @@ namespace swrenderer
fixed_t iscale = xs_Fix<16>::ToFix(MaskedSWall[x] * MaskedScaleY);
double sprtopscreen;
if (sprflipvert)
sprtopscreen = CenterY + dc_texturemid * spryscale;
sprtopscreen = CenterY + texturemid * spryscale;
else
sprtopscreen = CenterY - dc_texturemid * spryscale;
sprtopscreen = CenterY - texturemid * spryscale;
R_DrawMaskedColumn(x, iscale, tex, maskedtexturecol[x], spryscale, sprtopscreen, sprflipvert, mfloorclip, mceilingclip);
@ -373,13 +375,13 @@ namespace swrenderer
{
// rowoffset is added before the multiply so that the masked texture will
// still be positioned in world units rather than texels.
dc_texturemid = (dc_texturemid - ViewPos.Z + rowoffset) * MaskedScaleY;
texturemid = (texturemid - ViewPos.Z + rowoffset) * MaskedScaleY;
}
else
{
// rowoffset is added outside the multiply so that it positions the texture
// by texels instead of world units.
dc_texturemid = (dc_texturemid - ViewPos.Z) * MaskedScaleY + rowoffset;
texturemid = (texturemid - ViewPos.Z) * MaskedScaleY + rowoffset;
}
WallC.sz1 = ds->sz1;
@ -421,7 +423,7 @@ namespace swrenderer
rw_offset = 0;
rw_pic = tex;
R_DrawDrawSeg(frontsector, curline, WallC, rw_pic, ds, x1, x2, mceilingclip, mfloorclip, MaskedSWall, maskedtexturecol, ds->yscale, wallshade, rw_offset, rw_light, rw_lightstep, ds->foggy, basecolormap);
R_DrawDrawSeg(frontsector, curline, WallC, rw_pic, ds, x1, x2, mceilingclip, mfloorclip, texturemid, MaskedSWall, maskedtexturecol, ds->yscale, wallshade, rw_offset, rw_light, rw_lightstep, ds->foggy, basecolormap);
}
clearfog:
@ -498,20 +500,20 @@ namespace swrenderer
{
rowoffset += rw_pic->GetHeight();
}
dc_texturemid = (planez - ViewPos.Z) * yscale;
double texturemid = (planez - ViewPos.Z) * yscale;
if (rw_pic->bWorldPanning)
{
// rowoffset is added before the multiply so that the masked texture will
// still be positioned in world units rather than texels.
dc_texturemid = dc_texturemid + rowoffset * yscale;
texturemid = texturemid + rowoffset * yscale;
rw_offset = xs_RoundToInt(rw_offset * xscale);
}
else
{
// rowoffset is added outside the multiply so that it positions the texture
// by texels instead of world units.
dc_texturemid += rowoffset;
texturemid += rowoffset;
}
if (fixedlightlev >= 0)
@ -545,7 +547,7 @@ namespace swrenderer
}
PrepLWall(lwall, curline->sidedef->TexelLength*xscale, ds->sx1, ds->sx2, WallT);
R_DrawDrawSeg(frontsector, curline, WallC, rw_pic, ds, x1, x2, wallupper, walllower, MaskedSWall, lwall, yscale, wallshade, rw_offset, rw_light, rw_lightstep, ds->foggy, basecolormap);
R_DrawDrawSeg(frontsector, curline, WallC, rw_pic, ds, x1, x2, wallupper, walllower, texturemid, MaskedSWall, lwall, yscale, wallshade, rw_offset, rw_light, rw_lightstep, ds->foggy, basecolormap);
}
// kg3D - walls of fake floors

View file

@ -214,7 +214,7 @@ namespace swrenderer
}
yscale = decal->ScaleY;
dc_texturemid = WallSpriteTile->TopOffset + (zpos - ViewPos.Z) / yscale;
double texturemid = WallSpriteTile->TopOffset + (zpos - ViewPos.Z) / yscale;
// Clip sprite to drawseg
x1 = MAX<int>(clipper->x1, x1);
@ -265,7 +265,7 @@ namespace swrenderer
{
sprflipvert = true;
yscale = -yscale;
dc_texturemid -= WallSpriteTile->GetHeight();
texturemid -= WallSpriteTile->GetHeight();
}
else
{
@ -293,7 +293,7 @@ namespace swrenderer
{ // calculate lighting
R_SetColorMapLight(usecolormap, light, wallshade);
}
DrawColumn(x, WallSpriteTile, maskedScaleY, sprflipvert, mfloorclip, mceilingclip);
DrawColumn(x, WallSpriteTile, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip);
light += lightstep;
x++;
}
@ -312,15 +312,15 @@ namespace swrenderer
WallC = savecoord;
}
void RenderDecal::DrawColumn(int x, FTexture *WallSpriteTile, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip)
void RenderDecal::DrawColumn(int x, FTexture *WallSpriteTile, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip)
{
float iscale = swall[x] * maskedScaleY;
double spryscale = 1 / iscale;
double sprtopscreen;
if (sprflipvert)
sprtopscreen = CenterY + dc_texturemid * spryscale;
sprtopscreen = CenterY + texturemid * spryscale;
else
sprtopscreen = CenterY - dc_texturemid * spryscale;
sprtopscreen = CenterY - texturemid * spryscale;
R_DrawMaskedColumn(x, FLOAT2FIXED(iscale), WallSpriteTile, lwall[x], spryscale, sprtopscreen, sprflipvert, mfloorclip, mceilingclip);
}

View file

@ -27,6 +27,6 @@ namespace swrenderer
private:
static void Render(side_t *wall, DBaseDecal *first, drawseg_t *clipper, int wallshade, float lightleft, float lightstep, seg_t *curline, FWallCoords wallC, bool foggy, FDynamicColormap *basecolormap, int pass);
static void DrawColumn(int x, FTexture *WallSpriteTile, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip);
static void DrawColumn(int x, FTexture *WallSpriteTile, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip);
};
}

View file

@ -314,20 +314,20 @@ namespace swrenderer
fixed_t iscale = FLOAT2FIXED(1 / vis->yscale);
frac = vis->startfrac;
xiscale = vis->xiscale;
dc_texturemid = vis->texturemid;
double texturemid = vis->texturemid;
if (vis->renderflags & RF_YFLIP)
{
sprflipvert = true;
spryscale = -spryscale;
iscale = -iscale;
dc_texturemid -= vis->pic->GetHeight();
sprtopscreen = CenterY + dc_texturemid * spryscale;
texturemid -= vis->pic->GetHeight();
sprtopscreen = CenterY + texturemid * spryscale;
}
else
{
sprflipvert = false;
sprtopscreen = CenterY - dc_texturemid * spryscale;
sprtopscreen = CenterY - texturemid * spryscale;
}
int x = vis->x1;

View file

@ -153,7 +153,7 @@ namespace swrenderer
WallT.InitFromWallCoords(&spr->wallc);
PrepWall(swall, lwall, spr->pic->GetWidth() << FRACBITS, x1, x2, WallT);
iyscale = 1 / spr->yscale;
dc_texturemid = (spr->gzt - ViewPos.Z) * iyscale;
double texturemid = (spr->gzt - ViewPos.Z) * iyscale;
if (spr->renderflags & RF_XFLIP)
{
int right = (spr->pic->GetWidth() << FRACBITS) - 1;
@ -195,7 +195,7 @@ namespace swrenderer
{
sprflipvert = true;
iyscale = -iyscale;
dc_texturemid -= spr->pic->GetHeight();
texturemid -= spr->pic->GetHeight();
}
else
{
@ -229,22 +229,22 @@ namespace swrenderer
R_SetColorMapLight(usecolormap, light, shade);
}
if (!RenderTranslucentPass::ClipSpriteColumnWithPortals(x, spr))
DrawColumn(x, WallSpriteTile, maskedScaleY, sprflipvert, mfloorclip, mceilingclip);
DrawColumn(x, WallSpriteTile, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip);
light += lightstep;
x++;
}
}
}
void RenderWallSprite::DrawColumn(int x, FTexture *WallSpriteTile, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip)
void RenderWallSprite::DrawColumn(int x, FTexture *WallSpriteTile, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip)
{
float iscale = swall[x] * maskedScaleY;
double spryscale = 1 / iscale;
double sprtopscreen;
if (sprflipvert)
sprtopscreen = CenterY + dc_texturemid * spryscale;
sprtopscreen = CenterY + texturemid * spryscale;
else
sprtopscreen = CenterY - dc_texturemid * spryscale;
sprtopscreen = CenterY - texturemid * spryscale;
R_DrawMaskedColumn(x, FLOAT2FIXED(iscale), WallSpriteTile, lwall[x], spryscale, sprtopscreen, sprflipvert, mfloorclip, mceilingclip);
}

View file

@ -24,6 +24,6 @@ namespace swrenderer
static void Render(vissprite_t *spr, const short *mfloorclip, const short *mceilingclip);
private:
static void DrawColumn(int x, FTexture *WallSpriteTile, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip);
static void DrawColumn(int x, FTexture *WallSpriteTile, double texturemid, float maskedScaleY, bool sprflipvert, const short *mfloorclip, const short *mceilingclip);
};
}