diff --git a/src/r_bsp.h b/src/r_bsp.h index ba302c686..48ca7565b 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -82,7 +82,7 @@ struct drawseg_t ptrdiff_t sprtopclip; // type short ptrdiff_t sprbottomclip; // type short ptrdiff_t maskedtexturecol; // type short - ptrdiff_t swall; // type fixed_t + ptrdiff_t swall; // type float int fake; // ident fake drawseg, don't draw and clip sprites // backups ptrdiff_t bkup; // sprtopclip backup, for mid and fake textures diff --git a/src/r_draw.h b/src/r_draw.h index 72b51dfa4..cb2f68f33 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -285,12 +285,12 @@ bool R_GetTransMaskDrawers (fixed_t (**tmvline1)(), void (**tmvline4)()); // to just use the texture's GetColumn() method. It just exists // for double-layer skies. const BYTE *R_GetColumn (FTexture *tex, int col); -void wallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, fixed_t yrepeat, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn); +void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn); // maskwallscan is exactly like wallscan but does not draw anything where the texture is color 0. -void maskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, fixed_t yrepeat, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn); +void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn); // transmaskwallscan is like maskwallscan, but it can also blend to the background -void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, fixed_t yrepeat, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn); +void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, const BYTE *(*getcol)(FTexture *tex, int col)=R_GetColumn); #endif diff --git a/src/r_main.cpp b/src/r_main.cpp index 92e131e26..62360f647 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -383,7 +383,7 @@ void R_SWRSetWindow(int windowSize, int fullWidth, int fullHeight, int stHeight, IYaspectMul = (double)virtwidth * r_Yaspect / 320.0 / virtheight; InvZtoScale = YaspectMul * CenterX; - WallTMapScale2 = IYaspectMul * (1 << 18) / CenterX; + WallTMapScale2 = IYaspectMul / CenterX; // psprite scales pspritexscale = centerxwide / 160.0; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 40fbba1f5..6cf52e2c8 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -848,7 +848,7 @@ static double skymid; static angle_t skyangle; static double frontiScale; -extern fixed_t swall[MAXWIDTH]; +extern float swall[MAXWIDTH]; extern fixed_t lwall[MAXWIDTH]; extern fixed_t rw_offset; extern FTexture *rw_pic; @@ -916,13 +916,16 @@ static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x) static void R_DrawSky (visplane_t *pl) { int x; + float swal; if (pl->left >= pl->right) return; - dc_iscale = skyiscale; - - clearbuf (swall+pl->left, pl->right-pl->left, dc_iscale<<2); + swal = skyiscale; + for (x = pl->left; x < pl->right; ++x) + { + swall[x] = swal; + } if (MirrorFlags & RF_XFLIP) { @@ -957,20 +960,12 @@ static void R_DrawSky (visplane_t *pl) lastskycol[x] = 0xffffffff; } wallscan (pl->left, pl->right, (short *)pl->top, (short *)pl->bottom, swall, lwall, - FLOAT2FIXED(frontyScale), backskytex == NULL ? R_GetOneSkyColumn : R_GetTwoSkyColumns); + frontyScale, backskytex == NULL ? R_GetOneSkyColumn : R_GetTwoSkyColumns); } else { // The texture does not tile nicely frontyScale *= skyscale; frontiScale = 1 / frontyScale; - // Sodding crap. Fixed point sucks when you want precision. - // TODO (if I'm feeling adventurous): Rewrite the renderer to use floating point - // coordinates to keep as much precision as possible until the final - // rasterization stage so fudges like this aren't needed. - if (viewheight <= 600) - { - skymid -= 1; - } R_DrawSkyStriped (pl); } } @@ -989,7 +984,6 @@ static void R_DrawSkyStriped (visplane_t *pl) yl = 0; yh = short((frontskytex->GetHeight() - topfrac) * frontyScale); dc_texturemid = topfrac - iscale * (1 - CenterY); - fixed_t yScale = FLOAT2FIXED(rw_pic->Scale.Y); while (yl < viewheight) { @@ -1002,7 +996,7 @@ static void R_DrawSkyStriped (visplane_t *pl) { lastskycol[x] = 0xffffffff; } - wallscan (pl->left, pl->right, top, bot, swall, lwall, yScale, + wallscan (pl->left, pl->right, top, bot, swall, lwall, rw_pic->Scale.Y, backskytex == NULL ? R_GetOneSkyColumn : R_GetTwoSkyColumns); yl = yh; yh += drawheight; diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 6d71fc11e..1ef0d76b0 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -91,7 +91,7 @@ short walltop[MAXWIDTH]; // [RH] record max extents of wall short wallbottom[MAXWIDTH]; short wallupper[MAXWIDTH]; short walllower[MAXWIDTH]; -fixed_t swall[MAXWIDTH]; +float swall[MAXWIDTH]; fixed_t lwall[MAXWIDTH]; double lwallscale; @@ -136,9 +136,9 @@ static fixed_t *maskedtexturecol; static void R_RenderDecal (side_t *wall, DBaseDecal *first, drawseg_t *clipper, int pass); static void WallSpriteColumn (void (*drawfunc)(const BYTE *column, const FTexture::Span *spans)); -void wallscan_np2(int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, fixed_t yrepeat, double top, double bot, bool mask); -static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, fixed_t yrepeat); -static void call_wallscan(int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, fixed_t yrepeat, bool mask); +void wallscan_np2(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, double top, double bot, bool mask); +static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat); +static void call_wallscan(int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat, bool mask); //============================================================================= // @@ -169,8 +169,8 @@ CVAR(Bool, r_drawmirrors, true, 0) // // R_RenderMaskedSegRange // -fixed_t *MaskedSWall; -double MaskedScaleY; +float *MaskedSWall; +float MaskedScaleY; static void BlastMaskedColumn (void (*blastfunc)(const BYTE *pixels, const FTexture::Span *spans), FTexture *tex) { @@ -180,7 +180,7 @@ static void BlastMaskedColumn (void (*blastfunc)(const BYTE *pixels, const FText dc_colormap = basecolormap->Maps + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); } - dc_iscale = xs_RoundToInt(MaskedSWall[dc_x] * MaskedScaleY); + dc_iscale = xs_Fix<16>::ToFix(MaskedSWall[dc_x] * MaskedScaleY); if (sprflipvert) sprtopscreen = CenterY + dc_texturemid * spryscale; else @@ -305,7 +305,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) goto clearfog; } - MaskedSWall = (fixed_t *)(openings + ds->swall) - ds->x1; + MaskedSWall = (float *)(openings + ds->swall) - ds->x1; MaskedScaleY = ds->yscale; maskedtexturecol = (fixed_t *)(openings + ds->maskedtexturecol) - ds->x1; spryscale = ds->iscale + ds->iscalestep * (x1 - ds->x1); @@ -433,7 +433,6 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) mfloorclip = walllower; mceilingclip = wallupper; - MaskedScaleY /= 4; // [RH] Wish I could remember why this needs to be done // draw the columns one at a time if (drawmode == DoDraw0) @@ -531,7 +530,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) rw_offset = 0; rw_pic = tex; - wallscan_np2_ds(ds, x1, x2, mceilingclip, mfloorclip, MaskedSWall, maskedtexturecol, FLOAT2FIXED(ds->yscale)); + wallscan_np2_ds(ds, x1, x2, mceilingclip, mfloorclip, MaskedSWall, maskedtexturecol, ds->yscale); } clearfog: @@ -580,7 +579,7 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) spryscale = ds->iscale + ds->iscalestep * (x1 - ds->x1); rw_scalestep = ds->iscalestep; - MaskedSWall = (fixed_t *)(openings + ds->swall) - ds->x1; + MaskedSWall = (float *)(openings + ds->swall) - ds->x1; // find positioning side_t *scaledside; @@ -656,7 +655,7 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) } PrepLWall (lwall, curline->sidedef->TexelLength*xscale, ds->sx1, ds->sx2); - wallscan_np2_ds(ds, x1, x2, wallupper, walllower, MaskedSWall, lwall, FLOAT2FIXED(yscale)); + wallscan_np2_ds(ds, x1, x2, wallupper, walllower, MaskedSWall, lwall, yscale); R_FinishSetPatchStyle(); } @@ -1074,15 +1073,16 @@ inline fixed_t prevline1 (fixed_t vince, BYTE *colormap, int count, fixed_t vplc return doprevline1 (); } -void wallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, - fixed_t yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) +void wallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, + double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) { - int x, shiftval; + int x, fracbits; int y1ve[4], y2ve[4], u4, d4, z; char bad; float light = rw_light - rw_lightstep; - SDWORD texturemid, xoffset; + SDWORD xoffset; BYTE *basecolormapdata; + double iscale; // This function also gets used to draw skies. Unlike BUILD, skies are // drawn by visplane instead of by bunch, so these checks are invalid. @@ -1098,13 +1098,10 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t //clock (WallScanCycles); rw_pic->GetHeight(); // Make sure texture size is loaded - shiftval = rw_pic->HeightBits; - setupvline (32-shiftval); - yrepeat >>= 2 + shiftval; - texturemid = xs_ToFixed(32 - shiftval, dc_texturemid); + fracbits = 32 - rw_pic->HeightBits; + setupvline(fracbits); xoffset = rw_offset; basecolormapdata = basecolormap->Maps; - fixed_t centeryfrac = FLOAT2FIXED(CenterY); x = x1; //while ((umost[x] > dmost[x]) && (x < x2)) x++; @@ -1134,9 +1131,10 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); dc_dest = ylookup[y1ve[0]] + x + dc_destorg; - dc_iscale = swal[x] * yrepeat; dc_count = y2ve[0] - y1ve[0]; - dc_texturefrac = texturemid + FixedMul (dc_iscale, (y1ve[0]<> FRACBITS); - vince[z] = swal[x+z] * yrepeat; - vplce[z] = texturemid + FixedMul (vince[z], (y1ve[z]<> FRACBITS); dc_dest = ylookup[y1ve[0]] + x + dc_destorg; - dc_iscale = swal[x] * yrepeat; dc_count = y2ve[0] - y1ve[0]; - dc_texturefrac = texturemid + FixedMul (dc_iscale, (y1ve[0]<GetHeight(); double partition; - double yrepeat = FIXED2FLOAT(yrep); double scaledtexheight = texheight / yrepeat; if (yrepeat >= 0) @@ -1351,14 +1350,14 @@ void wallscan_np2(int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed { down[j] = clamp(most3[j], up[j], dwal[j]); } - call_wallscan(x1, x2, up, down, swal, lwal, yrep, mask); + call_wallscan(x1, x2, up, down, swal, lwal, yrepeat, mask); up = down; down = (down == most1) ? most2 : most1; } partition -= scaledtexheight; dc_texturemid -= texheight; } - call_wallscan(x1, x2, up, dwal, swal, lwal, yrep, mask); + call_wallscan(x1, x2, up, dwal, swal, lwal, yrepeat, mask); } else { // upside down: draw strips from bottom to top @@ -1375,19 +1374,19 @@ void wallscan_np2(int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed { up[j] = clamp(most3[j], uwal[j], down[j]); } - call_wallscan(x1, x2, up, down, swal, lwal, yrep, mask); + call_wallscan(x1, x2, up, down, swal, lwal, yrepeat, mask); down = up; up = (up == most1) ? most2 : most1; } partition -= scaledtexheight; dc_texturemid -= texheight; } - call_wallscan(x1, x2, uwal, down, swal, lwal, yrep, mask); + call_wallscan(x1, x2, uwal, down, swal, lwal, yrepeat, mask); } } } -static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, fixed_t yrepeat) +static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, double yrepeat) { if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) { @@ -1424,16 +1423,17 @@ inline fixed_t mvline1 (fixed_t vince, BYTE *colormap, int count, fixed_t vplce, return domvline1 (); } -void maskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t *lwal, - fixed_t yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) +void maskwallscan (int x1, int x2, short *uwal, short *dwal, float *swal, fixed_t *lwal, + double yrepeat, const BYTE *(*getcol)(FTexture *tex, int x)) { - int x, shiftval; + int x, fracbits; BYTE *p; int y1ve[4], y2ve[4], u4, d4, startx, dax, z; char bad; float light = rw_light - rw_lightstep; - SDWORD texturemid, xoffset; + SDWORD xoffset; BYTE *basecolormapdata; + double iscale; if (rw_pic->UseType == FTexture::TEX_Null) { @@ -1450,13 +1450,10 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixe //clock (WallScanCycles); rw_pic->GetHeight(); // Make sure texture size is loaded - shiftval = rw_pic->HeightBits; - setupmvline (32-shiftval); - yrepeat >>= 2 + shiftval; - texturemid = xs_ToFixed(32 - shiftval, dc_texturemid); + fracbits = 32- rw_pic->HeightBits; + setupmvline(fracbits); xoffset = rw_offset; basecolormapdata = basecolormap->Maps; - fixed_t centeryfrac = FLOAT2FIXED(CenterY); x = startx = x1; p = x + dc_destorg; @@ -1484,9 +1481,10 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixe dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); dc_dest = ylookup[y1ve[0]] + p; - dc_iscale = swal[x] * yrepeat; dc_count = y2ve[0] - y1ve[0]; - dc_texturefrac = texturemid + FixedMul (dc_iscale, (y1ve[0]<> FRACBITS); - vince[z] = swal[dax] * yrepeat; - vplce[z] = texturemid + FixedMul (vince[z], (y1ve[z]<> FRACBITS); dc_dest = ylookup[y1ve[0]] + p; - dc_iscale = swal[x] * yrepeat; dc_count = y2ve[0] - y1ve[0]; - dc_texturefrac = texturemid + FixedMul (dc_iscale, (y1ve[0]<UseType == FTexture::TEX_Null) { @@ -1624,10 +1625,8 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, //clock (WallScanCycles); rw_pic->GetHeight(); // Make sure texture size is loaded - shiftval = rw_pic->HeightBits; - setuptmvline (32-shiftval); - yrepeat >>= 2 + shiftval; - texturemid = xs_ToFixed(32 - shiftval, dc_texturemid); + fracbits = 32 - rw_pic->HeightBits; + setuptmvline(fracbits); xoffset = rw_offset; basecolormapdata = basecolormap->Maps; fixed_t centeryfrac = FLOAT2FIXED(CenterY); @@ -1658,9 +1657,10 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, dc_source = getcol (rw_pic, (lwal[x] + xoffset) >> FRACBITS); dc_dest = ylookup[y1ve[0]] + p; - dc_iscale = swal[x] * yrepeat; dc_count = y2ve[0] - y1ve[0]; - dc_texturefrac = texturemid + FixedMul (dc_iscale, (y1ve[0]<> FRACBITS); - vince[z] = swal[dax] * yrepeat; - vplce[z] = texturemid + FixedMul (vince[z], (y1ve[z]<> FRACBITS); dc_dest = ylookup[y1ve[0]] + p; - dc_iscale = swal[x] * yrepeat; dc_count = y2ve[0] - y1ve[0]; - dc_texturefrac = texturemid + FixedMul (dc_iscale, (y1ve[0]<= 0) @@ -1868,7 +1870,7 @@ void R_RenderSegLoop () dc_texturemid = rw_midtexturemid; rw_pic = midtexture; xscale = rw_pic->Scale.X * rw_midtexturescalex; - yscale = FLOAT2FIXED(rw_pic->Scale.Y * rw_midtexturescaley); + yscale = rw_pic->Scale.Y * rw_midtexturescaley; if (xscale != lwallscale) { PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2); @@ -1911,7 +1913,7 @@ void R_RenderSegLoop () dc_texturemid = rw_toptexturemid; rw_pic = toptexture; xscale = rw_pic->Scale.X * rw_toptexturescalex; - yscale = FLOAT2FIXED(rw_pic->Scale.Y * rw_toptexturescaley); + yscale = rw_pic->Scale.Y * rw_toptexturescaley; if (xscale != lwallscale) { PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2); @@ -1957,7 +1959,7 @@ void R_RenderSegLoop () dc_texturemid = rw_bottomtexturemid; rw_pic = bottomtexture; xscale = rw_pic->Scale.X * rw_bottomtexturescalex; - yscale = FLOAT2FIXED(rw_pic->Scale.Y * rw_bottomtexturescaley); + yscale = rw_pic->Scale.Y * rw_bottomtexturescaley; if (xscale != lwallscale) { PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2); @@ -2228,7 +2230,7 @@ void R_NewWall (bool needlights) rowoffset = sidedef->GetTextureYOffsetF(side_t::bottom); rw_bottomtexturescalex = FIXED2DBL(sidedef->GetTextureXScale(side_t::bottom)); rw_bottomtexturescaley = FIXED2DBL(sidedef->GetTextureYScale(side_t::bottom)); - yrepeat = fixed_t(bottomtexture->Scale.Y * rw_bottomtexturescaley); + yrepeat = bottomtexture->Scale.Y * rw_bottomtexturescaley; if (yrepeat >= 0) { // normal orientation if (linedef->flags & ML_DONTPEGBOTTOM) @@ -2492,7 +2494,7 @@ void R_StoreWallRange (int start, int stop) (rw_floorstat != 3 || !sidedef->GetTexture(side_t::bottom).isValid()) && (WallC.sz1 >= TOO_CLOSE_Z && WallC.sz2 >= TOO_CLOSE_Z)) { - fixed_t *swal; + float *swal; fixed_t *lwal; int i; @@ -2512,7 +2514,7 @@ void R_StoreWallRange (int start, int stop) ds_p->swall = R_NewOpening ((stop - start) * 2); lwal = (fixed_t *)(openings + ds_p->maskedtexturecol); - swal = (fixed_t *)(openings + ds_p->swall); + swal = (float *)(openings + ds_p->swall); FTexture *pic = TexMan(sidedef->GetTexture(side_t::mid), true); double yscale = pic->Scale.X * sidedef->GetTextureYScaleF(side_t::mid); fixed_t xoffset = sidedef->GetTextureXOffset(side_t::mid); @@ -2528,8 +2530,8 @@ void R_StoreWallRange (int start, int stop) *swal++ = swall[i]; } - double istart = *((fixed_t *)(openings + ds_p->swall)) * yscale / (1 << 18); - double iend = *(swal - 1) * yscale / (1 << 18); + double istart = *((float *)(openings + ds_p->swall)) * yscale; + double iend = *(swal - 1) * yscale; #if 0 ///This was for avoiding overflow when using fixed point. It might not be needed anymore. const double mini = 3 / 65536.0; @@ -2965,7 +2967,7 @@ static void PrepWallRoundFix(fixed_t *lwall, fixed_t walxrepeat, int x1, int x2) } } -void PrepWall (fixed_t *swall, fixed_t *lwall, double walxrepeat, int x1, int x2) +void PrepWall (float *swall, fixed_t *lwall, double walxrepeat, int x1, int x2) { // swall = scale, lwall = texturecolumn double top, bot, i; double xrepeat = fabs(walxrepeat * 65536); @@ -2987,7 +2989,7 @@ void PrepWall (fixed_t *swall, fixed_t *lwall, double walxrepeat, int x1, int x2 { lwall[x] = xs_RoundToInt(frac * xrepeat); } - swall[x] = xs_RoundToInt(frac * depth_scale + depth_org); + swall[x] = float(frac * depth_scale + depth_org); top += WallT.UoverZstep; bot += WallT.InvZstep; } @@ -3235,9 +3237,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, sprflipvert = false; } - // rw_offset is used as the texture's vertical scale - rw_offset = FLOAT2FIXED(1 / yscale); - + MaskedScaleY = float(1 / yscale); do { dc_x = x1; diff --git a/src/r_segs.h b/src/r_segs.h index 7d1703423..1fc428c96 100644 --- a/src/r_segs.h +++ b/src/r_segs.h @@ -33,7 +33,7 @@ extern size_t maxopenings; int OWallMost (short *mostbuf, double z, const FWallCoords *wallc); int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc); -void PrepWall (fixed_t *swall, fixed_t *lwall, double walxrepeat, int x1, int x2); +void PrepWall (float *swall, fixed_t *lwall, double walxrepeat, int x1, int x2); void PrepLWall (fixed_t *lwall, double walxrepeat, int x1, int x2); ptrdiff_t R_NewOpening (ptrdiff_t len); @@ -42,7 +42,7 @@ void R_CheckDrawSegs (); void R_RenderSegLoop (); -extern fixed_t swall[MAXWIDTH]; +extern float swall[MAXWIDTH]; extern fixed_t lwall[MAXWIDTH]; extern float rw_light; // [RH] Scale lights with viewsize adjustments extern float rw_lightstep; diff --git a/src/r_sky.cpp b/src/r_sky.cpp index 727d0bbbf..0e0bc412a 100644 --- a/src/r_sky.cpp +++ b/src/r_sky.cpp @@ -41,8 +41,8 @@ FTextureID skyflatnum; FTextureID sky1texture, sky2texture; double skytexturemid; -fixed_t skyscale; -fixed_t skyiscale; +double skyscale; +float skyiscale; bool skystretch; fixed_t sky1cyl, sky2cyl; @@ -54,7 +54,7 @@ CUSTOM_CVAR (Bool, r_stretchsky, true, CVAR_ARCHIVE) R_InitSkyMap (); } -fixed_t freelookviewheight; +int freelookviewheight; //========================================================================== // @@ -112,19 +112,18 @@ void R_InitSkyMap () if (viewwidth != 0 && viewheight != 0) { - skyiscale = (r_Yaspect*FRACUNIT) / ((freelookviewheight * viewwidth) / viewwidth); - skyscale = (((freelookviewheight * viewwidth) / viewwidth) << FRACBITS) / - (r_Yaspect); + skyiscale = float(r_Yaspect / freelookviewheight); + skyscale = freelookviewheight / r_Yaspect; - skyiscale = Scale (skyiscale, FieldOfView, 2048); - skyscale = Scale (skyscale, 2048, FieldOfView); + skyiscale *= FieldOfView / 2048.f; + skyscale *= 2048.0 / FieldOfView; } if (skystretch) { - skyscale = Scale(skyscale, SKYSTRETCH_HEIGHT, skyheight); - skyiscale = Scale(skyiscale, skyheight, SKYSTRETCH_HEIGHT); - skytexturemid = skytexturemid * skyheight / SKYSTRETCH_HEIGHT; + skyscale *= (double)SKYSTRETCH_HEIGHT / skyheight; + skyiscale *= skyheight / (float)SKYSTRETCH_HEIGHT; + skytexturemid *= skyheight / (double)SKYSTRETCH_HEIGHT; } // The standard Doom sky texture is 256 pixels wide, repeated 4 times over 360 degrees, diff --git a/src/r_sky.h b/src/r_sky.h index 30b106185..6ece74d74 100644 --- a/src/r_sky.h +++ b/src/r_sky.h @@ -30,10 +30,10 @@ extern fixed_t sky1cyl, sky2cyl; extern FTextureID sky1texture, sky2texture; extern double sky1pos, sky2pos; extern double skytexturemid; -extern fixed_t skyiscale; -extern fixed_t skyscale; +extern float skyiscale; +extern double skyscale; extern bool skystretch; -extern fixed_t freelookviewheight; +extern int freelookviewheight; #define SKYSTRETCH_HEIGHT 228 diff --git a/src/r_things.cpp b/src/r_things.cpp index 3cda3cb91..ed77170fd 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -89,7 +89,7 @@ struct FCoverageBuffer }; extern double globaluclip, globaldclip; - +extern float MaskedScaleY; #define MINZ double((2048*4) / double(1 << 20)) #define BASEYCENTER (100) @@ -558,8 +558,7 @@ void R_DrawWallSprite(vissprite_t *spr) sprflipvert = false; } - // rw_offset is used as the texture's vertical scale - rw_offset = xs_Fix<30>::ToFix(iyscale); + MaskedScaleY = (float)iyscale; dc_x = x1; ESPSResult mode; @@ -632,8 +631,9 @@ void R_DrawWallSprite(vissprite_t *spr) void R_WallSpriteColumn (void (*drawfunc)(const BYTE *column, const FTexture::Span *spans)) { - dc_iscale = MulScale16 (swall[dc_x], rw_offset/4); - spryscale = 65536.0 / dc_iscale; + float iscale = swall[dc_x] * MaskedScaleY; + dc_iscale = FLOAT2FIXED(iscale); + spryscale = 1 / iscale; if (sprflipvert) sprtopscreen = CenterY + dc_texturemid * spryscale; else diff --git a/src/r_utility.h b/src/r_utility.h index 1cdfda6eb..d1de9336c 100644 --- a/src/r_utility.h +++ b/src/r_utility.h @@ -39,7 +39,7 @@ extern DWORD r_FrameTime; extern int extralight; extern unsigned int R_OldBlend; -const int r_Yaspect = 200; // Why did I make this a variable? It's never set anywhere. +const double r_Yaspect = 200.0; // Why did I make this a variable? It's never set anywhere. //========================================================================== //