From e08da03a3d29720f791642898256ef42db4819bb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 29 Apr 2007 12:07:27 +0000 Subject: [PATCH] - Increased precision of texture scaling factors to full fixed point. In the process I got rid of the old tx and ty CVARs because they made the texture scaling much more complicated than it was actually needed (and besides, they were completely useless except for testing purposes anyway.) SVN r522 (trunk) --- docs/rh-log.txt | 4 ++ src/g_doom/doom_sbar.cpp | 10 +--- src/p_doors.cpp | 3 +- src/p_sectors.cpp | 10 ++-- src/r_anim.cpp | 7 ++- src/r_data.cpp | 17 +++--- src/r_defs.h | 35 ++++++++++-- src/r_plane.cpp | 39 +++++++------- src/r_segs.cpp | 86 ++++++++++++++---------------- src/r_sky.cpp | 4 +- src/r_things.cpp | 24 ++++----- src/textures/multipatchtexture.cpp | 10 +--- src/textures/texture.cpp | 6 +-- src/textures/warptexture.cpp | 10 +--- src/v_font.cpp | 12 +---- 15 files changed, 133 insertions(+), 144 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index c87ebe2ae..3450b5e9e 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,8 @@ April 29, 2007 (Changes by Graf Zahl) +- Increased precision of texture scaling factors to full fixed point. In the process + I got rid of the old tx and ty CVARs because they made the texture scaling + much more complicated than it was actually needed (and besides, they were completely + useless except for testing purposes anyway.) - Added a simple check for abstract weapon classes so that I can properly define the DoomWeapon base class. - Fixed: When the Tome of Power runs out it must also set any pending weapon diff --git a/src/g_doom/doom_sbar.cpp b/src/g_doom/doom_sbar.cpp index 4912df5a5..2938ba599 100644 --- a/src/g_doom/doom_sbar.cpp +++ b/src/g_doom/doom_sbar.cpp @@ -1050,15 +1050,7 @@ FDoomStatusBar::FDoomStatusBarTexture::FDoomStatusBarTexture () Name[0]=0; // doesn't need a name // now copy all the properties from the base texture - Width = BaseTexture->GetWidth(); - Height = BaseTexture->GetHeight(); - TopOffset = BaseTexture->TopOffset; - LeftOffset = BaseTexture->LeftOffset; - WidthBits = BaseTexture->WidthBits; - HeightBits = BaseTexture->HeightBits; - ScaleX = BaseTexture->ScaleX; - ScaleY = BaseTexture->ScaleY; - WidthMask = (1 << WidthBits) - 1; + CopySize(BaseTexture); Pixels = NULL; } diff --git a/src/p_doors.cpp b/src/p_doors.cpp index b333edfb1..7a2562e99 100644 --- a/src/p_doors.cpp +++ b/src/p_doors.cpp @@ -714,8 +714,7 @@ DAnimatedDoor::DAnimatedDoor (sector_t *sec, line_t *line, int speed, int delay) // don't forget texture scaling here! FTexture *tex = TexMan[picnum]; - topdist = tex ? (tex->GetHeight() * 8 / (tex->ScaleY ? tex->ScaleY : 8)) : 64; - //topdist = TexMan[picnum]->GetHeight(); // old non-scaling sensitive code! + topdist = tex ? tex->GetScaledHeight() : 64; topdist = m_Sector->ceilingplane.d - topdist * m_Sector->ceilingplane.c; diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index e305b72fc..e9b057b44 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -454,11 +454,13 @@ static inline void CheckShortestTex (int texnum, fixed_t &minsize) if (texnum > 0 || (texnum == 0 && (i_compatflags & COMPATF_SHORTTEX))) { FTexture *tex = TexMan[texnum]; - int yscale = tex->ScaleY ? tex->ScaleY : 8; - fixed_t h = DivScale19 (tex->GetHeight(), yscale); - if (h < minsize) + if (tex != NULL) { - minsize = h; + fixed_t h = tex->GetScaledHeight()<GetWidth (), oldtex->ScaleX ? oldtex->ScaleX : 8); - fitheight = DivScale3 (oldtex->GetHeight (), oldtex->ScaleY ? oldtex->ScaleY : 8); + fitwidth = oldtex->GetScaledWidth (); + fitheight = oldtex->GetScaledHeight (); viewer->UseType = oldtex->UseType; TexMan.ReplaceTexture (picnum, viewer, true); } @@ -367,8 +367,7 @@ static void R_InitAnimDefs () SC_UnGet (); } } - viewer->ScaleX = width * 8 / fitwidth; - viewer->ScaleY = height * 8 / fitheight; + viewer->SetScaledSize(fitwidth, fitheight); } else if (SC_Compare ("animatedDoor")) { diff --git a/src/r_data.cpp b/src/r_data.cpp index 49b5c2dd1..2e2ac2a24 100644 --- a/src/r_data.cpp +++ b/src/r_data.cpp @@ -347,10 +347,9 @@ void FTextureManager::AddHiresTextures () FTexture * oldtex = Textures[oldtexno].Texture; // Replace the entire texture and adjust the scaling and offset factors. - newtex->ScaleX = 8 * newtex->GetWidth() / oldtex->GetWidth(); - newtex->ScaleY = 8 * newtex->GetHeight() / oldtex->GetHeight(); - newtex->LeftOffset = Scale(oldtex->LeftOffset, newtex->ScaleX, 8); - newtex->TopOffset = Scale(oldtex->TopOffset, newtex->ScaleY, 8); + newtex->SetScaledSize(oldtex->GetScaledWidth(), oldtex->GetScaledHeight()); + newtex->LeftOffset = FixedMul(oldtex->GetScaledLeftOffset(), newtex->xScale); + newtex->TopOffset = FixedMul(oldtex->GetScaledTopOffset(), newtex->yScale); ReplaceTexture(oldtexno, newtex, true); } StartScreen->Progress(); @@ -413,10 +412,9 @@ void FTextureManager::LoadHiresTex() { // Replace the entire texture and adjust the scaling and offset factors. newtex->bWorldPanning = true; - newtex->ScaleX = 8 * newtex->GetWidth() / oldtex->GetScaledWidth(); - newtex->ScaleY = 8 * newtex->GetHeight() / oldtex->GetScaledHeight(); - newtex->LeftOffset = MulScale3(oldtex->GetScaledLeftOffset(), newtex->ScaleX); - newtex->TopOffset = MulScale3(oldtex->GetScaledTopOffset(), newtex->ScaleY); + newtex->SetScaledSize(oldtex->GetScaledWidth(), oldtex->GetScaledHeight()); + newtex->LeftOffset = FixedMul(oldtex->GetScaledLeftOffset(), newtex->xScale); + newtex->TopOffset = FixedMul(oldtex->GetScaledTopOffset(), newtex->yScale); ReplaceTexture(tex, newtex, true); } } @@ -446,8 +444,7 @@ void FTextureManager::LoadHiresTex() { // Replace the entire texture and adjust the scaling and offset factors. newtex->bWorldPanning = true; - newtex->ScaleX = 8 * newtex->GetWidth() / width; - newtex->ScaleY = 8 * newtex->GetHeight() / height; + newtex->SetScaledSize(width, height); memcpy(newtex->Name, src, sizeof(newtex->Name)); int oldtex = TexMan.CheckForTexture(src, FTexture::TEX_Override); diff --git a/src/r_defs.h b/src/r_defs.h index b694b17c4..18751ce7a 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -599,7 +599,10 @@ public: SWORD LeftOffset, TopOffset; BYTE WidthBits, HeightBits; - BYTE ScaleX, ScaleY; + //BYTE ScaleX, ScaleY; + + fixed_t xScale; + fixed_t yScale; char Name[9]; BYTE UseType; // This texture's primary purpose @@ -649,11 +652,11 @@ public: int GetWidth () { return Width; } int GetHeight () { return Height; } - int GetScaledWidth () { return ScaleX ? DivScale3(Width, ScaleX) : Width; } - int GetScaledHeight () { return ScaleY ? DivScale3(Height, ScaleY) : Height; } + int GetScaledWidth () { return DivScale16(Width, xScale); } + int GetScaledHeight () { return DivScale16(Height, yScale); } - int GetScaledLeftOffset () { return ScaleX ? DivScale3(LeftOffset, ScaleX) : LeftOffset; } - int GetScaledTopOffset () { return ScaleY ? DivScale3(TopOffset, ScaleY) : TopOffset; } + int GetScaledLeftOffset () { return DivScale16(LeftOffset, xScale); } + int GetScaledTopOffset () { return DivScale16(TopOffset, yScale); } virtual void SetFrontSkyLayer(); @@ -665,6 +668,28 @@ public: virtual bool CheckModified (); static void InitGrayMap(); + void CopySize(FTexture *BaseTexture) + { + Width = BaseTexture->GetWidth(); + Height = BaseTexture->GetHeight(); + TopOffset = BaseTexture->TopOffset; + LeftOffset = BaseTexture->LeftOffset; + WidthBits = BaseTexture->WidthBits; + HeightBits = BaseTexture->HeightBits; + xScale = BaseTexture->xScale; + yScale = BaseTexture->yScale; + WidthMask = (1 << WidthBits) - 1; + } + + void SetScaledSize(int fitwidth, int fitheight) + { + xScale = DivScale16(Width, fitwidth); + yScale = DivScale16(Height,fitheight); + // compensate for roundoff errors + if (MulScale16(xScale, fitwidth) != Width) xScale++; + if (MulScale16(yScale, fitheight) != Height) yScale++; + } + protected: WORD Width, Height, WidthMask; static BYTE GrayMap[256]; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 20e4fa025..6638b5f8c 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -51,8 +51,8 @@ #include "vectors.h" #include "a_sharedglobal.h" -EXTERN_CVAR (Int, tx) -EXTERN_CVAR (Int, ty) +//EXTERN_CVAR (Int, tx) +//EXTERN_CVAR (Int, ty) static void R_DrawSkyStriped (visplane_t *pl); @@ -731,8 +731,9 @@ inline void R_MakeSpans (int x, int t1, int b1, int t2, int b2, void (*mapfunc)( static FTexture *frontskytex, *backskytex; static angle_t skyflip; static int frontpos, backpos; -static int frontxscale, backxscale; -static int frontyscale, frontiscale; +static fixed_t frontxScale, backxScale; +static fixed_t frontyScale; +int frontiScale; extern fixed_t swall[MAXWIDTH]; extern fixed_t lwall[MAXWIDTH]; @@ -749,7 +750,7 @@ static int skycolplace; // Get a column of sky when there is only one sky texture. static const BYTE *R_GetOneSkyColumn (FTexture *fronttex, int x) { - angle_t column = MulScale3 (frontxscale, viewangle + xtoviewangle[x]); + angle_t column = MulScale16 (frontxScale, viewangle + xtoviewangle[x]); return fronttex->GetColumn ((((column^skyflip) >> sky1shift) + frontpos) >> FRACBITS, NULL); } @@ -758,8 +759,8 @@ static const BYTE *R_GetOneSkyColumn (FTexture *fronttex, int x) static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x) { DWORD ang = (viewangle + xtoviewangle[x])^skyflip; - DWORD angle1 = (((DWORD)MulScale3 (frontxscale, ang) >> sky1shift) + frontpos) >> FRACBITS; - DWORD angle2 = (((DWORD)MulScale3 (backxscale, ang) >> sky2shift) + backpos) >> FRACBITS; + DWORD angle1 = (((DWORD)MulScale16 (frontxScale, ang) >> sky1shift) + frontpos) >> FRACBITS; + DWORD angle2 = (((DWORD)MulScale16 (backxScale, ang) >> sky2shift) + backpos) >> FRACBITS; // Check if this column has already been built. If so, there's // no reason to waste time building it again. @@ -804,7 +805,7 @@ static void R_DrawSky (visplane_t *pl) { int x; - if (pl->minx > pl->maxx) + if (pl->minx > pl->maxx) return; dc_iscale = skyiscale >> skystretch; @@ -835,14 +836,14 @@ static void R_DrawSky (visplane_t *pl) rw_pic = frontskytex; rw_offset = 0; - frontxscale = rw_pic->ScaleX ? rw_pic->ScaleX : tx; + frontxScale = rw_pic->xScale; if (backskytex != NULL) { - backxscale = backskytex->ScaleX ? backskytex->ScaleX : tx; + backxScale = backskytex->xScale; } - frontyscale = rw_pic->ScaleY ? rw_pic->ScaleY : ty; - dc_texturemid = MulScale3 (skytexturemid/*-viewz*/, frontyscale); + frontyScale = rw_pic->yScale; + dc_texturemid = MulScale16 (skytexturemid/*-viewz*/, frontyScale); if (1 << frontskytex->HeightBits == frontskytex->GetHeight()) { // The texture tiles nicely @@ -855,8 +856,8 @@ static void R_DrawSky (visplane_t *pl) } else { // The texture does not tile nicely - frontyscale = DivScale3 (skyscale << skystretch, frontyscale); - frontiscale = DivScale32 (1, frontyscale); + frontyScale = DivScale16 (skyscale << skystretch, frontyScale); + frontiScale = DivScale32 (1, frontyScale); R_DrawSkyStriped (pl); } } @@ -864,9 +865,9 @@ static void R_DrawSky (visplane_t *pl) static void R_DrawSkyStriped (visplane_t *pl) { fixed_t centerysave = centeryfrac; - short drawheight = (short)MulScale16 (frontskytex->GetHeight(), frontyscale); + short drawheight = (short)MulScale16 (frontskytex->GetHeight(), frontyScale); fixed_t topfrac; - fixed_t iscale = frontiscale; + fixed_t iscale = frontiScale; short top[MAXWIDTH], bot[MAXWIDTH]; short yl, yh; int x; @@ -877,7 +878,7 @@ static void R_DrawSkyStriped (visplane_t *pl) topfrac = (skytexturemid + iscale * (1-centery)) % (frontskytex->GetHeight() << FRACBITS); if (topfrac < 0) topfrac += frontskytex->GetHeight() << FRACBITS; yl = 0; - yh = (short)MulScale32 ((frontskytex->GetHeight() << FRACBITS) - topfrac, frontyscale); + yh = (short)MulScale32 ((frontskytex->GetHeight() << FRACBITS) - topfrac, frontyScale); dc_texturemid = topfrac - iscale * (1-centery); while (yl < viewheight) @@ -981,8 +982,8 @@ void R_DrawSinglePlane (visplane_t *pl, fixed_t alpha, bool masked) { ds_ybits--; } - pl->xscale = MulScale3 (pl->xscale, tex->ScaleX ? tex->ScaleX : 8); - pl->yscale = MulScale3 (pl->yscale, tex->ScaleY ? tex->ScaleY : 8); + pl->xscale = MulScale16 (pl->xscale, tex->xScale); + pl->yscale = MulScale16 (pl->yscale, tex->yScale); #ifdef USEASM R_SetSpanSize_ASM (ds_xbits, ds_ybits); #endif diff --git a/src/r_segs.cpp b/src/r_segs.cpp index aa3dbe880..116f994b1 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -47,8 +47,8 @@ #define WALLYREPEAT 8 -CVAR (Int, ty, 8, 0) -CVAR (Int, tx, 8, 0) +//CVAR (Int, ty, 8, 0) +//CVAR (Int, tx, 8, 0) #define HEIGHTBITS 12 #define HEIGHTSHIFT (FRACBITS-HEIGHTBITS) @@ -88,7 +88,7 @@ short wallupper[MAXWIDTH]; short walllower[MAXWIDTH]; fixed_t swall[MAXWIDTH]; fixed_t lwall[MAXWIDTH]; -int lwallscale; +fixed_t lwallscale; // // regular wall @@ -169,7 +169,7 @@ static void BlastMaskedColumn (void (*blastfunc)(const BYTE *pixels, const FText dc_colormap = basecolormap + (GETPALOOKUP (rw_light, wallshade) << COLORMAPSHIFT); } - dc_iscale = MulScale5 (MaskedSWall[dc_x], MaskedScaleY); + dc_iscale = MulScale18 (MaskedSWall[dc_x], MaskedScaleY); sprtopscreen = centeryfrac - FixedMul (dc_texturemid, spryscale); // killough 1/25/98: here's where Medusa came in, because @@ -195,7 +195,7 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) FTexture *tex; int i; sector_t tempsec; // killough 4/13/98 - fixed_t texheight, textop, scaley; + fixed_t texheight, textop; sprflipvert = false; @@ -244,14 +244,13 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) } MaskedSWall = (fixed_t *)(openings + ds->swall) - ds->x1; - MaskedScaleY = tex->ScaleY ? tex->ScaleY : ty; + MaskedScaleY = tex->yScale; maskedtexturecol = (fixed_t *)(openings + ds->maskedtexturecol) - ds->x1; spryscale = ds->iscale + ds->iscalestep * (x1 - ds->x1); rw_scalestep = ds->iscalestep; // find positioning - scaley = tex->ScaleY ? tex->ScaleY : ty; - texheight = SafeDivScale19 (tex->GetHeight(), scaley); + texheight = tex->GetScaledHeight() << FRACBITS; if (curline->linedef->flags & ML_DONTPEGBOTTOM) { dc_texturemid = MAX (frontsector->floortexz, backsector->floortexz) + texheight; @@ -266,14 +265,14 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2) // still be positioned in world units rather than texels. dc_texturemid += curline->sidedef->rowoffset - viewz; textop = dc_texturemid; - dc_texturemid = MulScale3 (dc_texturemid, scaley); + dc_texturemid = MulScale16 (dc_texturemid, tex->yScale); } else { // rowoffset is added outside the multiply so that it positions the texture // by texels instead of world units. - textop = dc_texturemid - viewz + SafeDivScale3 (curline->sidedef->rowoffset, scaley); - dc_texturemid = MulScale3 (dc_texturemid - viewz, scaley) + curline->sidedef->rowoffset; + textop = dc_texturemid - viewz + SafeDivScale16 (curline->sidedef->rowoffset, tex->yScale); + dc_texturemid = MulScale16 (dc_texturemid - viewz, tex->yScale) + curline->sidedef->rowoffset; } if (fixedlightlev) @@ -421,7 +420,7 @@ void wallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixed_t rw_pic->GetHeight(); // Make sure texture size is loaded shiftval = rw_pic->HeightBits; setupvline (32-shiftval); - yrepeat = (rw_pic->ScaleY ? rw_pic->ScaleY : ty) << (11 - shiftval); + yrepeat = rw_pic->yScale >> (2 + shiftval); texturemid = dc_texturemid << (16 - shiftval); xoffset = rw_offset; @@ -668,7 +667,7 @@ void maskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, fixe rw_pic->GetHeight(); // Make sure texture size is loaded shiftval = rw_pic->HeightBits; setupmvline (32-shiftval); - yrepeat = (rw_pic->ScaleY ? rw_pic->ScaleY : ty) << (11 - shiftval); + yrepeat = rw_pic->yScale >> (2 + shiftval); texturemid = dc_texturemid << (16 - shiftval); xoffset = rw_offset; @@ -838,7 +837,7 @@ void transmaskwallscan (int x1, int x2, short *uwal, short *dwal, fixed_t *swal, rw_pic->GetHeight(); // Make sure texture size is loaded shiftval = rw_pic->HeightBits; setuptmvline (32-shiftval); - yrepeat = (rw_pic->ScaleY ? rw_pic->ScaleY : ty) << (11 - shiftval); + yrepeat = rw_pic->yScale >> (2 + shiftval); texturemid = dc_texturemid << (16 - shiftval); xoffset = rw_offset; @@ -1045,15 +1044,15 @@ void R_RenderSegLoop () { dc_texturemid = rw_midtexturemid; rw_pic = midtexture; - xscale = rw_pic->ScaleX ? rw_pic->ScaleX : tx; + xscale = rw_pic->xScale; if (xscale != lwallscale) { - PrepLWall (lwall, (curline->sidedef->TexelLength*xscale) << (FRACBITS-3)); + PrepLWall (lwall, curline->sidedef->TexelLength*xscale); lwallscale = xscale; } if (midtexture->bWorldPanning) { - rw_offset = MulScale3 (xoffset, midtexture->ScaleX ? midtexture->ScaleX : tx); + rw_offset = MulScale16 (xoffset, midtexture->xScale); } if (fixedlightlev || fixedcolormap || !frontsector->ExtraLights) { @@ -1079,15 +1078,15 @@ void R_RenderSegLoop () { dc_texturemid = rw_toptexturemid; rw_pic = toptexture; - xscale = rw_pic->ScaleX ? rw_pic->ScaleX : tx; + xscale = rw_pic->xScale; if (xscale != lwallscale) { - PrepLWall (lwall, (curline->sidedef->TexelLength*xscale) << (FRACBITS-3)); + PrepLWall (lwall, curline->sidedef->TexelLength*xscale); lwallscale = xscale; } if (toptexture->bWorldPanning) { - rw_offset = MulScale3 (xoffset, toptexture->ScaleX ? toptexture->ScaleX : tx); + rw_offset = MulScale16 (xoffset, toptexture->xScale); } if (fixedlightlev || fixedcolormap || !frontsector->ExtraLights) { @@ -1116,15 +1115,15 @@ void R_RenderSegLoop () { dc_texturemid = rw_bottomtexturemid; rw_pic = bottomtexture; - xscale = rw_pic->ScaleX ? rw_pic->ScaleX : tx; + xscale = rw_pic->xScale; if (xscale != lwallscale) { - PrepLWall (lwall, (curline->sidedef->TexelLength*xscale) << (FRACBITS-3)); + PrepLWall (lwall, curline->sidedef->TexelLength*xscale); lwallscale = xscale; } if (bottomtexture->bWorldPanning) { - rw_offset = MulScale3 (xoffset, bottomtexture->ScaleX ? bottomtexture->ScaleX : tx); + rw_offset = MulScale16 (xoffset, bottomtexture->xScale); } else { @@ -1190,15 +1189,13 @@ void R_NewWall (bool needlights) } if (midtexture->bWorldPanning) { - rw_midtexturemid = MulScale3 (rw_midtexturemid - viewz + rowoffset, - midtexture->ScaleY ? midtexture->ScaleY : ty); + rw_midtexturemid = MulScale16 (rw_midtexturemid - viewz + rowoffset, midtexture->yScale); } else { // rowoffset is added outside the multiply so that it positions the texture // by texels instead of world units. - rw_midtexturemid = MulScale3 (rw_midtexturemid - viewz, - midtexture->ScaleY ? midtexture->ScaleY : ty) + rw_midtexturemid = MulScale16 (rw_midtexturemid - viewz, midtexture->yScale) + rowoffset; } } @@ -1304,12 +1301,12 @@ void R_NewWall (bool needlights) if (rw_havehigh) { // top texture toptexture = TexMan(sidedef->toptexture); - const int scale = toptexture->ScaleY ? toptexture->ScaleY : ty; + const fixed_t scale = toptexture->yScale; rowoffset = sidedef->rowoffset; if (linedef->flags & ML_DONTPEGTOP) { // top of texture at top - rw_toptexturemid = MulScale3 (frontsector->ceilingtexz - viewz, scale); + rw_toptexturemid = MulScale16 (frontsector->ceilingtexz - viewz, scale); if (rowoffset < 0 && toptexture != NULL) { rowoffset += toptexture->GetHeight() << FRACBITS; @@ -1317,11 +1314,11 @@ void R_NewWall (bool needlights) } else { // bottom of texture at bottom - rw_toptexturemid = MulScale3 (backsector->ceilingtexz - viewz, scale) + (toptexture->GetHeight() << FRACBITS); + rw_toptexturemid = MulScale16 (backsector->ceilingtexz - viewz, scale) + (toptexture->GetHeight() << FRACBITS); } if (toptexture->bWorldPanning) { - rw_toptexturemid += MulScale3 (rowoffset, scale); + rw_toptexturemid += MulScale16 (rowoffset, scale); } else { @@ -1347,13 +1344,12 @@ void R_NewWall (bool needlights) } if (bottomtexture->bWorldPanning) { - rw_bottomtexturemid = MulScale3 (rw_bottomtexturemid - viewz + rowoffset, - bottomtexture->ScaleY ? bottomtexture->ScaleY : ty); + rw_bottomtexturemid = MulScale16 (rw_bottomtexturemid - viewz + rowoffset, + bottomtexture->yScale); } else { - rw_bottomtexturemid = MulScale3 (rw_bottomtexturemid - viewz, - bottomtexture->ScaleY ? bottomtexture->ScaleY : ty) + rw_bottomtexturemid = MulScale16 (rw_bottomtexturemid - viewz, bottomtexture->yScale) + rowoffset; } } @@ -1378,14 +1374,11 @@ void R_NewWall (bool needlights) // calculate light table if (needlights && (segtextured || (backsector && IsFogBoundary (frontsector, backsector)))) { - lwallscale = TexMan(sidedef->midtexture) ? TexMan(sidedef->midtexture)->ScaleX : - toptexture ? toptexture->ScaleX : - bottomtexture ? bottomtexture->ScaleX : 0; - if (lwallscale == 0) - { - lwallscale = tx; - } - PrepWall (swall, lwall, (sidedef->TexelLength*lwallscale) << (FRACBITS-3)); + lwallscale = TexMan(sidedef->midtexture) ? TexMan(sidedef->midtexture)->xScale : + toptexture ? toptexture->xScale : + bottomtexture ? bottomtexture->xScale : FRACUNIT; + + PrepWall (swall, lwall, sidedef->TexelLength*lwallscale); if (!fixedcolormap) { @@ -1588,8 +1581,7 @@ void R_StoreWallRange (int start, int stop) lwal = (fixed_t *)(openings + ds_p->maskedtexturecol); swal = (fixed_t *)(openings + ds_p->swall); - int scaley = TexMan(sidedef->midtexture)->ScaleY ? - TexMan(sidedef->midtexture)->ScaleY : ty; + int scaley = TexMan(sidedef->midtexture)->yScale; int xoffset = rw_offset; for (i = start; i < stop; i++) { @@ -1597,8 +1589,8 @@ void R_StoreWallRange (int start, int stop) *swal++ = swall[i]; } - fixed_t istart = MulScale5 (*((fixed_t *)(openings + ds_p->swall)), scaley); - fixed_t iend = MulScale5 (*(swal - 1), scaley); + fixed_t istart = MulScale18 (*((fixed_t *)(openings + ds_p->swall)), scaley); + fixed_t iend = MulScale18 (*(swal - 1), scaley); if (istart < 3 && istart >= 0) istart = 3; if (istart > -3 && istart < 0) istart = -3; diff --git a/src/r_sky.cpp b/src/r_sky.cpp index ec719f739..bee0977f1 100644 --- a/src/r_sky.cpp +++ b/src/r_sky.cpp @@ -86,7 +86,7 @@ void R_InitSkyMap () } fskyheight = skytex1->GetHeight() << FRACBITS; - if (DivScale3 (fskyheight, skytex1->ScaleY ? skytex1->ScaleY : 8) <= (128 << FRACBITS)) + if (skytex1->GetScaledHeight() <= 128) { skytexturemid = r_Yaspect/2*FRACUNIT; skystretch = (r_stretchsky @@ -95,7 +95,7 @@ void R_InitSkyMap () } else { - skytexturemid = MulScale3 (199<ScaleY ? skytex1->ScaleY : 8); + skytexturemid = 199 * skytex1->yScale; skystretch = 0; } skyheight = fskyheight << skystretch; diff --git a/src/r_things.cpp b/src/r_things.cpp index e870bf8b8..9cf8e0f44 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1302,8 +1302,8 @@ void R_ProjectSprite (AActor *thing, int fakeside) } // [RH] Added scaling - gzt = fz + MulScale3(thing->scaleY, tex->TopOffset * tex->ScaleX); - gzb = fz + MulScale3(thing->scaleY, (tex->TopOffset - tex->GetHeight()) * tex->ScaleY); + gzt = fz + MulScale16(thing->scaleY, tex->TopOffset * tex->yScale); + gzb = fz + MulScale16(thing->scaleY, (tex->TopOffset - tex->GetHeight()) * tex->yScale); // [RH] Reject sprites that are off the top or bottom of the screen if (MulScale12 (globaluclip, tz) > viewz - gzb || @@ -1319,7 +1319,7 @@ void R_ProjectSprite (AActor *thing, int fakeside) } // calculate edges of the shape - const fixed_t thingxscalemul = MulScale3(thing->scaleX, tex->ScaleX); + const fixed_t thingxscalemul = MulScale16(thing->scaleX, tex->xScale); tx -= (flip ? (tex->GetWidth() - tex->LeftOffset - 1) : tex->LeftOffset) * thingxscalemul; x1 = centerx + MulScale32 (tx, xscale); @@ -1335,7 +1335,7 @@ void R_ProjectSprite (AActor *thing, int fakeside) if (x2 < WindowLeft || x2 <= x1) return; - xscale = MulScale19 (thing->scaleX, xscale * tex->ScaleX); + xscale = FixedMul(FixedMul(thing->scaleX, xscale), tex->xScale); iscale = (tex->GetWidth() << FRACBITS) / (x2 - x1); x2--; @@ -1382,16 +1382,16 @@ void R_ProjectSprite (AActor *thing, int fakeside) vis->RenderStyle = thing->RenderStyle; vis->AlphaColor = thing->alphacolor; vis->xscale = xscale; - vis->yscale = Scale (InvZtoScale, MulScale3(thing->scaleY, tex->ScaleY), tz)>>4; + vis->yscale = Scale (InvZtoScale, MulScale16(thing->scaleY, tex->yScale), tz)>>4; vis->idepth = (DWORD)DivScale32 (1, tz) >> 1; // tz is 20.12, so idepth ought to be 12.20, but vis->cx = tx2; // signed math makes it 13.19 vis->gx = fx; vis->gy = fy; vis->gz = gzb; // [RH] use gzb, not thing->z vis->gzt = gzt; // killough 3/27/98 - vis->floorclip = FixedDiv (thing->floorclip, MulScale3(thing->scaleY, tex->ScaleY)); + vis->floorclip = FixedDiv (thing->floorclip, MulScale16(thing->scaleY, tex->yScale)); vis->texturemid = (tex->TopOffset << FRACBITS) - - FixedDiv (viewz-fz+thing->floorclip, MulScale3(thing->scaleY, tex->ScaleY)); + FixedDiv (viewz-fz+thing->floorclip, MulScale16(thing->scaleY, tex->yScale)); vis->x1 = x1 < WindowLeft ? WindowLeft : x1; vis->x2 = x2 > WindowRight ? WindowRight : x2; vis->Translation = thing->Translation; // [RH] thing translation table @@ -1528,7 +1528,7 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_ vis->floorclip = 0; - vis->texturemid = MulScale3((BASEYCENTER<ScaleY) + (tex->TopOffset << FRACBITS); + vis->texturemid = MulScale16((BASEYCENTER<yScale) + (tex->TopOffset << FRACBITS); if (camera->player && (RenderTarget != screen || @@ -1559,19 +1559,19 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_ } vis->x1 = x1 < 0 ? 0 : x1; vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; - vis->xscale = DivScale3(pspritexscale, tex->ScaleX); - vis->yscale = DivScale3(pspriteyscale, tex->ScaleY); + vis->xscale = DivScale16(pspritexscale, tex->xScale); + vis->yscale = DivScale16(pspriteyscale, tex->yScale); vis->Translation = 0; // [RH] Use default colors vis->pic = tex; if (flip) { - vis->xiscale = -MulScale3(pspritexiscale, tex->ScaleX); + vis->xiscale = -MulScale16(pspritexiscale, tex->xScale); vis->startfrac = (tex->GetWidth() << FRACBITS) - 1; } else { - vis->xiscale = MulScale3(pspritexiscale, tex->ScaleX); + vis->xiscale = MulScale16(pspritexiscale, tex->xScale); vis->startfrac = 0; } diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index 7b1c6d9b5..ead41cb24 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -97,14 +97,8 @@ FMultiPatchTexture::FMultiPatchTexture (const void *texdef, FPatchLookup *patchl CalcBitSize (); - // [RH] Special for beta 29: Values of 0 will use the tx/ty cvars - // to determine scaling instead of defaulting to 8. I will likely - // remove this once I finish the betas, because by then, users - // should be able to actually create scaled textures. - // 10-June-2003: It's still here long after beta 29. Heh. - - ScaleX = mtexture.d->ScaleX ? mtexture.d->ScaleX : 0; - ScaleY = mtexture.d->ScaleY ? mtexture.d->ScaleY : 0; + xScale = mtexture.d->ScaleX ? mtexture.d->ScaleX*(FRACUNIT/8) : FRACUNIT; + yScale = mtexture.d->ScaleY ? mtexture.d->ScaleY*(FRACUNIT/8) : FRACUNIT; if (mtexture.d->Flags & MAPTEXF_WORLDPANNING) { diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index 01c1bc13d..7d10c1f3f 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -96,12 +96,12 @@ FTexture * FTexture::CreateTexture (int lumpnum, int usetype) // Auto-scale flats with dimensions 128x128 and 256x256 if (w==128 && h==128) { - tex->ScaleX = tex->ScaleY = 16; + tex->xScale = tex->yScale = 2*FRACUNIT; tex->bWorldPanning = true; } else if (w==256 && h==256) { - tex->ScaleX = tex->ScaleY = 32; + tex->xScale = tex->yScale = 4*FRACUNIT; tex->bWorldPanning = true; } } @@ -114,7 +114,7 @@ FTexture * FTexture::CreateTexture (int lumpnum, int usetype) FTexture::FTexture () : LeftOffset(0), TopOffset(0), - WidthBits(0), HeightBits(0), ScaleX(8), ScaleY(8), + WidthBits(0), HeightBits(0), xScale(FRACUNIT), yScale(FRACUNIT), UseType(TEX_Any), bNoDecals(false), bNoRemap0(false), bWorldPanning(false), bMasked(true), bAlphaTexture(false), bHasCanvas(false), bWarped(0), bIsPatch(false), Rotations(0xFFFF), Width(0), Height(0), WidthMask(0) diff --git a/src/textures/warptexture.cpp b/src/textures/warptexture.cpp index 59bb1c179..eae089a53 100644 --- a/src/textures/warptexture.cpp +++ b/src/textures/warptexture.cpp @@ -42,15 +42,7 @@ FWarpTexture::FWarpTexture (FTexture *source) : SourcePic (source), Pixels (0), Spans (0), GenTime (0) { - Width = source->GetWidth (); - Height = source->GetHeight (); - LeftOffset = source->LeftOffset; - TopOffset = source->TopOffset; - WidthBits = source->WidthBits; - HeightBits = source->HeightBits; - WidthMask = (1 << WidthBits) - 1; - ScaleX = source->ScaleX; - ScaleY = source->ScaleY; + CopySize(source); bNoDecals = source->bNoDecals; Rotations = source->Rotations; bWarped = 1; diff --git a/src/v_font.cpp b/src/v_font.cpp index d2c167665..74fd38fc6 100644 --- a/src/v_font.cpp +++ b/src/v_font.cpp @@ -1042,15 +1042,7 @@ FFontChar1::FFontChar1 (int sourcelump, const BYTE *sourceremap) Name[0] = 0; // Make this texture unnamed // now copy all the properties from the base texture - Width = BaseTexture->GetWidth(); - Height = BaseTexture->GetHeight(); - TopOffset = BaseTexture->TopOffset; - LeftOffset = BaseTexture->LeftOffset; - WidthBits = BaseTexture->WidthBits; - HeightBits = BaseTexture->HeightBits; - ScaleX = BaseTexture->ScaleX; - ScaleY = BaseTexture->ScaleY; - WidthMask = (1 << WidthBits) - 1; + CopySize(BaseTexture); Pixels = NULL; } @@ -1947,4 +1939,4 @@ void V_InitFonts() } ConFont = new FSingleLumpFont ("ConsoleFont", Wads.GetNumForName ("CONFONT")); V_InitCustomFonts (); -} +}