- 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)
This commit is contained in:
Christoph Oelckers 2007-04-29 12:07:27 +00:00
parent 6e5b1f1182
commit e08da03a3d
15 changed files with 133 additions and 144 deletions

View file

@ -1,4 +1,8 @@
April 29, 2007 (Changes by Graf Zahl) 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 - Added a simple check for abstract weapon classes so that I can properly define
the DoomWeapon base class. the DoomWeapon base class.
- Fixed: When the Tome of Power runs out it must also set any pending weapon - Fixed: When the Tome of Power runs out it must also set any pending weapon

View file

@ -1050,15 +1050,7 @@ FDoomStatusBar::FDoomStatusBarTexture::FDoomStatusBarTexture ()
Name[0]=0; // doesn't need a name Name[0]=0; // doesn't need a name
// now copy all the properties from the base texture // now copy all the properties from the base texture
Width = BaseTexture->GetWidth(); CopySize(BaseTexture);
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;
Pixels = NULL; Pixels = NULL;
} }

View file

@ -714,8 +714,7 @@ DAnimatedDoor::DAnimatedDoor (sector_t *sec, line_t *line, int speed, int delay)
// don't forget texture scaling here! // don't forget texture scaling here!
FTexture *tex = TexMan[picnum]; FTexture *tex = TexMan[picnum];
topdist = tex ? (tex->GetHeight() * 8 / (tex->ScaleY ? tex->ScaleY : 8)) : 64; topdist = tex ? tex->GetScaledHeight() : 64;
//topdist = TexMan[picnum]->GetHeight(); // old non-scaling sensitive code!
topdist = m_Sector->ceilingplane.d - topdist * m_Sector->ceilingplane.c; topdist = m_Sector->ceilingplane.d - topdist * m_Sector->ceilingplane.c;

View file

@ -454,13 +454,15 @@ static inline void CheckShortestTex (int texnum, fixed_t &minsize)
if (texnum > 0 || (texnum == 0 && (i_compatflags & COMPATF_SHORTTEX))) if (texnum > 0 || (texnum == 0 && (i_compatflags & COMPATF_SHORTTEX)))
{ {
FTexture *tex = TexMan[texnum]; FTexture *tex = TexMan[texnum];
int yscale = tex->ScaleY ? tex->ScaleY : 8; if (tex != NULL)
fixed_t h = DivScale19 (tex->GetHeight(), yscale); {
fixed_t h = tex->GetScaledHeight()<<FRACBITS;
if (h < minsize) if (h < minsize)
{ {
minsize = h; minsize = h;
} }
} }
}
} }
fixed_t sector_t::FindShortestTextureAround () const fixed_t sector_t::FindShortestTextureAround () const

View file

@ -340,8 +340,8 @@ static void R_InitAnimDefs ()
if (picnum != -1) if (picnum != -1)
{ {
FTexture *oldtex = TexMan[picnum]; FTexture *oldtex = TexMan[picnum];
fitwidth = DivScale3 (oldtex->GetWidth (), oldtex->ScaleX ? oldtex->ScaleX : 8); fitwidth = oldtex->GetScaledWidth ();
fitheight = DivScale3 (oldtex->GetHeight (), oldtex->ScaleY ? oldtex->ScaleY : 8); fitheight = oldtex->GetScaledHeight ();
viewer->UseType = oldtex->UseType; viewer->UseType = oldtex->UseType;
TexMan.ReplaceTexture (picnum, viewer, true); TexMan.ReplaceTexture (picnum, viewer, true);
} }
@ -367,8 +367,7 @@ static void R_InitAnimDefs ()
SC_UnGet (); SC_UnGet ();
} }
} }
viewer->ScaleX = width * 8 / fitwidth; viewer->SetScaledSize(fitwidth, fitheight);
viewer->ScaleY = height * 8 / fitheight;
} }
else if (SC_Compare ("animatedDoor")) else if (SC_Compare ("animatedDoor"))
{ {

View file

@ -347,10 +347,9 @@ void FTextureManager::AddHiresTextures ()
FTexture * oldtex = Textures[oldtexno].Texture; FTexture * oldtex = Textures[oldtexno].Texture;
// Replace the entire texture and adjust the scaling and offset factors. // Replace the entire texture and adjust the scaling and offset factors.
newtex->ScaleX = 8 * newtex->GetWidth() / oldtex->GetWidth(); newtex->SetScaledSize(oldtex->GetScaledWidth(), oldtex->GetScaledHeight());
newtex->ScaleY = 8 * newtex->GetHeight() / oldtex->GetHeight(); newtex->LeftOffset = FixedMul(oldtex->GetScaledLeftOffset(), newtex->xScale);
newtex->LeftOffset = Scale(oldtex->LeftOffset, newtex->ScaleX, 8); newtex->TopOffset = FixedMul(oldtex->GetScaledTopOffset(), newtex->yScale);
newtex->TopOffset = Scale(oldtex->TopOffset, newtex->ScaleY, 8);
ReplaceTexture(oldtexno, newtex, true); ReplaceTexture(oldtexno, newtex, true);
} }
StartScreen->Progress(); StartScreen->Progress();
@ -413,10 +412,9 @@ void FTextureManager::LoadHiresTex()
{ {
// Replace the entire texture and adjust the scaling and offset factors. // Replace the entire texture and adjust the scaling and offset factors.
newtex->bWorldPanning = true; newtex->bWorldPanning = true;
newtex->ScaleX = 8 * newtex->GetWidth() / oldtex->GetScaledWidth(); newtex->SetScaledSize(oldtex->GetScaledWidth(), oldtex->GetScaledHeight());
newtex->ScaleY = 8 * newtex->GetHeight() / oldtex->GetScaledHeight(); newtex->LeftOffset = FixedMul(oldtex->GetScaledLeftOffset(), newtex->xScale);
newtex->LeftOffset = MulScale3(oldtex->GetScaledLeftOffset(), newtex->ScaleX); newtex->TopOffset = FixedMul(oldtex->GetScaledTopOffset(), newtex->yScale);
newtex->TopOffset = MulScale3(oldtex->GetScaledTopOffset(), newtex->ScaleY);
ReplaceTexture(tex, newtex, true); ReplaceTexture(tex, newtex, true);
} }
} }
@ -446,8 +444,7 @@ void FTextureManager::LoadHiresTex()
{ {
// Replace the entire texture and adjust the scaling and offset factors. // Replace the entire texture and adjust the scaling and offset factors.
newtex->bWorldPanning = true; newtex->bWorldPanning = true;
newtex->ScaleX = 8 * newtex->GetWidth() / width; newtex->SetScaledSize(width, height);
newtex->ScaleY = 8 * newtex->GetHeight() / height;
memcpy(newtex->Name, src, sizeof(newtex->Name)); memcpy(newtex->Name, src, sizeof(newtex->Name));
int oldtex = TexMan.CheckForTexture(src, FTexture::TEX_Override); int oldtex = TexMan.CheckForTexture(src, FTexture::TEX_Override);

View file

@ -599,7 +599,10 @@ public:
SWORD LeftOffset, TopOffset; SWORD LeftOffset, TopOffset;
BYTE WidthBits, HeightBits; BYTE WidthBits, HeightBits;
BYTE ScaleX, ScaleY; //BYTE ScaleX, ScaleY;
fixed_t xScale;
fixed_t yScale;
char Name[9]; char Name[9];
BYTE UseType; // This texture's primary purpose BYTE UseType; // This texture's primary purpose
@ -649,11 +652,11 @@ public:
int GetWidth () { return Width; } int GetWidth () { return Width; }
int GetHeight () { return Height; } int GetHeight () { return Height; }
int GetScaledWidth () { return ScaleX ? DivScale3(Width, ScaleX) : Width; } int GetScaledWidth () { return DivScale16(Width, xScale); }
int GetScaledHeight () { return ScaleY ? DivScale3(Height, ScaleY) : Height; } int GetScaledHeight () { return DivScale16(Height, yScale); }
int GetScaledLeftOffset () { return ScaleX ? DivScale3(LeftOffset, ScaleX) : LeftOffset; } int GetScaledLeftOffset () { return DivScale16(LeftOffset, xScale); }
int GetScaledTopOffset () { return ScaleY ? DivScale3(TopOffset, ScaleY) : TopOffset; } int GetScaledTopOffset () { return DivScale16(TopOffset, yScale); }
virtual void SetFrontSkyLayer(); virtual void SetFrontSkyLayer();
@ -665,6 +668,28 @@ public:
virtual bool CheckModified (); virtual bool CheckModified ();
static void InitGrayMap(); 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: protected:
WORD Width, Height, WidthMask; WORD Width, Height, WidthMask;
static BYTE GrayMap[256]; static BYTE GrayMap[256];

View file

@ -51,8 +51,8 @@
#include "vectors.h" #include "vectors.h"
#include "a_sharedglobal.h" #include "a_sharedglobal.h"
EXTERN_CVAR (Int, tx) //EXTERN_CVAR (Int, tx)
EXTERN_CVAR (Int, ty) //EXTERN_CVAR (Int, ty)
static void R_DrawSkyStriped (visplane_t *pl); 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 FTexture *frontskytex, *backskytex;
static angle_t skyflip; static angle_t skyflip;
static int frontpos, backpos; static int frontpos, backpos;
static int frontxscale, backxscale; static fixed_t frontxScale, backxScale;
static int frontyscale, frontiscale; static fixed_t frontyScale;
int frontiScale;
extern fixed_t swall[MAXWIDTH]; extern fixed_t swall[MAXWIDTH];
extern fixed_t lwall[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. // Get a column of sky when there is only one sky texture.
static const BYTE *R_GetOneSkyColumn (FTexture *fronttex, int x) 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); 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) static const BYTE *R_GetTwoSkyColumns (FTexture *fronttex, int x)
{ {
DWORD ang = (viewangle + xtoviewangle[x])^skyflip; DWORD ang = (viewangle + xtoviewangle[x])^skyflip;
DWORD angle1 = (((DWORD)MulScale3 (frontxscale, ang) >> sky1shift) + frontpos) >> FRACBITS; DWORD angle1 = (((DWORD)MulScale16 (frontxScale, ang) >> sky1shift) + frontpos) >> FRACBITS;
DWORD angle2 = (((DWORD)MulScale3 (backxscale, ang) >> sky2shift) + backpos) >> FRACBITS; DWORD angle2 = (((DWORD)MulScale16 (backxScale, ang) >> sky2shift) + backpos) >> FRACBITS;
// Check if this column has already been built. If so, there's // Check if this column has already been built. If so, there's
// no reason to waste time building it again. // no reason to waste time building it again.
@ -835,14 +836,14 @@ static void R_DrawSky (visplane_t *pl)
rw_pic = frontskytex; rw_pic = frontskytex;
rw_offset = 0; rw_offset = 0;
frontxscale = rw_pic->ScaleX ? rw_pic->ScaleX : tx; frontxScale = rw_pic->xScale;
if (backskytex != NULL) if (backskytex != NULL)
{ {
backxscale = backskytex->ScaleX ? backskytex->ScaleX : tx; backxScale = backskytex->xScale;
} }
frontyscale = rw_pic->ScaleY ? rw_pic->ScaleY : ty; frontyScale = rw_pic->yScale;
dc_texturemid = MulScale3 (skytexturemid/*-viewz*/, frontyscale); dc_texturemid = MulScale16 (skytexturemid/*-viewz*/, frontyScale);
if (1 << frontskytex->HeightBits == frontskytex->GetHeight()) if (1 << frontskytex->HeightBits == frontskytex->GetHeight())
{ // The texture tiles nicely { // The texture tiles nicely
@ -855,8 +856,8 @@ static void R_DrawSky (visplane_t *pl)
} }
else else
{ // The texture does not tile nicely { // The texture does not tile nicely
frontyscale = DivScale3 (skyscale << skystretch, frontyscale); frontyScale = DivScale16 (skyscale << skystretch, frontyScale);
frontiscale = DivScale32 (1, frontyscale); frontiScale = DivScale32 (1, frontyScale);
R_DrawSkyStriped (pl); R_DrawSkyStriped (pl);
} }
} }
@ -864,9 +865,9 @@ static void R_DrawSky (visplane_t *pl)
static void R_DrawSkyStriped (visplane_t *pl) static void R_DrawSkyStriped (visplane_t *pl)
{ {
fixed_t centerysave = centeryfrac; fixed_t centerysave = centeryfrac;
short drawheight = (short)MulScale16 (frontskytex->GetHeight(), frontyscale); short drawheight = (short)MulScale16 (frontskytex->GetHeight(), frontyScale);
fixed_t topfrac; fixed_t topfrac;
fixed_t iscale = frontiscale; fixed_t iscale = frontiScale;
short top[MAXWIDTH], bot[MAXWIDTH]; short top[MAXWIDTH], bot[MAXWIDTH];
short yl, yh; short yl, yh;
int x; int x;
@ -877,7 +878,7 @@ static void R_DrawSkyStriped (visplane_t *pl)
topfrac = (skytexturemid + iscale * (1-centery)) % (frontskytex->GetHeight() << FRACBITS); topfrac = (skytexturemid + iscale * (1-centery)) % (frontskytex->GetHeight() << FRACBITS);
if (topfrac < 0) topfrac += frontskytex->GetHeight() << FRACBITS; if (topfrac < 0) topfrac += frontskytex->GetHeight() << FRACBITS;
yl = 0; yl = 0;
yh = (short)MulScale32 ((frontskytex->GetHeight() << FRACBITS) - topfrac, frontyscale); yh = (short)MulScale32 ((frontskytex->GetHeight() << FRACBITS) - topfrac, frontyScale);
dc_texturemid = topfrac - iscale * (1-centery); dc_texturemid = topfrac - iscale * (1-centery);
while (yl < viewheight) while (yl < viewheight)
@ -981,8 +982,8 @@ void R_DrawSinglePlane (visplane_t *pl, fixed_t alpha, bool masked)
{ {
ds_ybits--; ds_ybits--;
} }
pl->xscale = MulScale3 (pl->xscale, tex->ScaleX ? tex->ScaleX : 8); pl->xscale = MulScale16 (pl->xscale, tex->xScale);
pl->yscale = MulScale3 (pl->yscale, tex->ScaleY ? tex->ScaleY : 8); pl->yscale = MulScale16 (pl->yscale, tex->yScale);
#ifdef USEASM #ifdef USEASM
R_SetSpanSize_ASM (ds_xbits, ds_ybits); R_SetSpanSize_ASM (ds_xbits, ds_ybits);
#endif #endif

View file

@ -47,8 +47,8 @@
#define WALLYREPEAT 8 #define WALLYREPEAT 8
CVAR (Int, ty, 8, 0) //CVAR (Int, ty, 8, 0)
CVAR (Int, tx, 8, 0) //CVAR (Int, tx, 8, 0)
#define HEIGHTBITS 12 #define HEIGHTBITS 12
#define HEIGHTSHIFT (FRACBITS-HEIGHTBITS) #define HEIGHTSHIFT (FRACBITS-HEIGHTBITS)
@ -88,7 +88,7 @@ short wallupper[MAXWIDTH];
short walllower[MAXWIDTH]; short walllower[MAXWIDTH];
fixed_t swall[MAXWIDTH]; fixed_t swall[MAXWIDTH];
fixed_t lwall[MAXWIDTH]; fixed_t lwall[MAXWIDTH];
int lwallscale; fixed_t lwallscale;
// //
// regular wall // 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_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); sprtopscreen = centeryfrac - FixedMul (dc_texturemid, spryscale);
// killough 1/25/98: here's where Medusa came in, because // 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; FTexture *tex;
int i; int i;
sector_t tempsec; // killough 4/13/98 sector_t tempsec; // killough 4/13/98
fixed_t texheight, textop, scaley; fixed_t texheight, textop;
sprflipvert = false; sprflipvert = false;
@ -244,14 +244,13 @@ void R_RenderMaskedSegRange (drawseg_t *ds, int x1, int x2)
} }
MaskedSWall = (fixed_t *)(openings + ds->swall) - ds->x1; 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; maskedtexturecol = (fixed_t *)(openings + ds->maskedtexturecol) - ds->x1;
spryscale = ds->iscale + ds->iscalestep * (x1 - ds->x1); spryscale = ds->iscale + ds->iscalestep * (x1 - ds->x1);
rw_scalestep = ds->iscalestep; rw_scalestep = ds->iscalestep;
// find positioning // find positioning
scaley = tex->ScaleY ? tex->ScaleY : ty; texheight = tex->GetScaledHeight() << FRACBITS;
texheight = SafeDivScale19 (tex->GetHeight(), scaley);
if (curline->linedef->flags & ML_DONTPEGBOTTOM) if (curline->linedef->flags & ML_DONTPEGBOTTOM)
{ {
dc_texturemid = MAX (frontsector->floortexz, backsector->floortexz) + texheight; 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. // still be positioned in world units rather than texels.
dc_texturemid += curline->sidedef->rowoffset - viewz; dc_texturemid += curline->sidedef->rowoffset - viewz;
textop = dc_texturemid; textop = dc_texturemid;
dc_texturemid = MulScale3 (dc_texturemid, scaley); dc_texturemid = MulScale16 (dc_texturemid, tex->yScale);
} }
else else
{ {
// rowoffset is added outside the multiply so that it positions the texture // rowoffset is added outside the multiply so that it positions the texture
// by texels instead of world units. // by texels instead of world units.
textop = dc_texturemid - viewz + SafeDivScale3 (curline->sidedef->rowoffset, scaley); textop = dc_texturemid - viewz + SafeDivScale16 (curline->sidedef->rowoffset, tex->yScale);
dc_texturemid = MulScale3 (dc_texturemid - viewz, scaley) + curline->sidedef->rowoffset; dc_texturemid = MulScale16 (dc_texturemid - viewz, tex->yScale) + curline->sidedef->rowoffset;
} }
if (fixedlightlev) 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 rw_pic->GetHeight(); // Make sure texture size is loaded
shiftval = rw_pic->HeightBits; shiftval = rw_pic->HeightBits;
setupvline (32-shiftval); setupvline (32-shiftval);
yrepeat = (rw_pic->ScaleY ? rw_pic->ScaleY : ty) << (11 - shiftval); yrepeat = rw_pic->yScale >> (2 + shiftval);
texturemid = dc_texturemid << (16 - shiftval); texturemid = dc_texturemid << (16 - shiftval);
xoffset = rw_offset; 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 rw_pic->GetHeight(); // Make sure texture size is loaded
shiftval = rw_pic->HeightBits; shiftval = rw_pic->HeightBits;
setupmvline (32-shiftval); setupmvline (32-shiftval);
yrepeat = (rw_pic->ScaleY ? rw_pic->ScaleY : ty) << (11 - shiftval); yrepeat = rw_pic->yScale >> (2 + shiftval);
texturemid = dc_texturemid << (16 - shiftval); texturemid = dc_texturemid << (16 - shiftval);
xoffset = rw_offset; 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 rw_pic->GetHeight(); // Make sure texture size is loaded
shiftval = rw_pic->HeightBits; shiftval = rw_pic->HeightBits;
setuptmvline (32-shiftval); setuptmvline (32-shiftval);
yrepeat = (rw_pic->ScaleY ? rw_pic->ScaleY : ty) << (11 - shiftval); yrepeat = rw_pic->yScale >> (2 + shiftval);
texturemid = dc_texturemid << (16 - shiftval); texturemid = dc_texturemid << (16 - shiftval);
xoffset = rw_offset; xoffset = rw_offset;
@ -1045,15 +1044,15 @@ void R_RenderSegLoop ()
{ {
dc_texturemid = rw_midtexturemid; dc_texturemid = rw_midtexturemid;
rw_pic = midtexture; rw_pic = midtexture;
xscale = rw_pic->ScaleX ? rw_pic->ScaleX : tx; xscale = rw_pic->xScale;
if (xscale != lwallscale) if (xscale != lwallscale)
{ {
PrepLWall (lwall, (curline->sidedef->TexelLength*xscale) << (FRACBITS-3)); PrepLWall (lwall, curline->sidedef->TexelLength*xscale);
lwallscale = xscale; lwallscale = xscale;
} }
if (midtexture->bWorldPanning) if (midtexture->bWorldPanning)
{ {
rw_offset = MulScale3 (xoffset, midtexture->ScaleX ? midtexture->ScaleX : tx); rw_offset = MulScale16 (xoffset, midtexture->xScale);
} }
if (fixedlightlev || fixedcolormap || !frontsector->ExtraLights) if (fixedlightlev || fixedcolormap || !frontsector->ExtraLights)
{ {
@ -1079,15 +1078,15 @@ void R_RenderSegLoop ()
{ {
dc_texturemid = rw_toptexturemid; dc_texturemid = rw_toptexturemid;
rw_pic = toptexture; rw_pic = toptexture;
xscale = rw_pic->ScaleX ? rw_pic->ScaleX : tx; xscale = rw_pic->xScale;
if (xscale != lwallscale) if (xscale != lwallscale)
{ {
PrepLWall (lwall, (curline->sidedef->TexelLength*xscale) << (FRACBITS-3)); PrepLWall (lwall, curline->sidedef->TexelLength*xscale);
lwallscale = xscale; lwallscale = xscale;
} }
if (toptexture->bWorldPanning) if (toptexture->bWorldPanning)
{ {
rw_offset = MulScale3 (xoffset, toptexture->ScaleX ? toptexture->ScaleX : tx); rw_offset = MulScale16 (xoffset, toptexture->xScale);
} }
if (fixedlightlev || fixedcolormap || !frontsector->ExtraLights) if (fixedlightlev || fixedcolormap || !frontsector->ExtraLights)
{ {
@ -1116,15 +1115,15 @@ void R_RenderSegLoop ()
{ {
dc_texturemid = rw_bottomtexturemid; dc_texturemid = rw_bottomtexturemid;
rw_pic = bottomtexture; rw_pic = bottomtexture;
xscale = rw_pic->ScaleX ? rw_pic->ScaleX : tx; xscale = rw_pic->xScale;
if (xscale != lwallscale) if (xscale != lwallscale)
{ {
PrepLWall (lwall, (curline->sidedef->TexelLength*xscale) << (FRACBITS-3)); PrepLWall (lwall, curline->sidedef->TexelLength*xscale);
lwallscale = xscale; lwallscale = xscale;
} }
if (bottomtexture->bWorldPanning) if (bottomtexture->bWorldPanning)
{ {
rw_offset = MulScale3 (xoffset, bottomtexture->ScaleX ? bottomtexture->ScaleX : tx); rw_offset = MulScale16 (xoffset, bottomtexture->xScale);
} }
else else
{ {
@ -1190,15 +1189,13 @@ void R_NewWall (bool needlights)
} }
if (midtexture->bWorldPanning) if (midtexture->bWorldPanning)
{ {
rw_midtexturemid = MulScale3 (rw_midtexturemid - viewz + rowoffset, rw_midtexturemid = MulScale16 (rw_midtexturemid - viewz + rowoffset, midtexture->yScale);
midtexture->ScaleY ? midtexture->ScaleY : ty);
} }
else else
{ {
// rowoffset is added outside the multiply so that it positions the texture // rowoffset is added outside the multiply so that it positions the texture
// by texels instead of world units. // by texels instead of world units.
rw_midtexturemid = MulScale3 (rw_midtexturemid - viewz, rw_midtexturemid = MulScale16 (rw_midtexturemid - viewz, midtexture->yScale)
midtexture->ScaleY ? midtexture->ScaleY : ty)
+ rowoffset; + rowoffset;
} }
} }
@ -1304,12 +1301,12 @@ void R_NewWall (bool needlights)
if (rw_havehigh) if (rw_havehigh)
{ // top texture { // top texture
toptexture = TexMan(sidedef->toptexture); toptexture = TexMan(sidedef->toptexture);
const int scale = toptexture->ScaleY ? toptexture->ScaleY : ty; const fixed_t scale = toptexture->yScale;
rowoffset = sidedef->rowoffset; rowoffset = sidedef->rowoffset;
if (linedef->flags & ML_DONTPEGTOP) if (linedef->flags & ML_DONTPEGTOP)
{ // top of texture at top { // top of texture at top
rw_toptexturemid = MulScale3 (frontsector->ceilingtexz - viewz, scale); rw_toptexturemid = MulScale16 (frontsector->ceilingtexz - viewz, scale);
if (rowoffset < 0 && toptexture != NULL) if (rowoffset < 0 && toptexture != NULL)
{ {
rowoffset += toptexture->GetHeight() << FRACBITS; rowoffset += toptexture->GetHeight() << FRACBITS;
@ -1317,11 +1314,11 @@ void R_NewWall (bool needlights)
} }
else else
{ // bottom of texture at bottom { // 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) if (toptexture->bWorldPanning)
{ {
rw_toptexturemid += MulScale3 (rowoffset, scale); rw_toptexturemid += MulScale16 (rowoffset, scale);
} }
else else
{ {
@ -1347,13 +1344,12 @@ void R_NewWall (bool needlights)
} }
if (bottomtexture->bWorldPanning) if (bottomtexture->bWorldPanning)
{ {
rw_bottomtexturemid = MulScale3 (rw_bottomtexturemid - viewz + rowoffset, rw_bottomtexturemid = MulScale16 (rw_bottomtexturemid - viewz + rowoffset,
bottomtexture->ScaleY ? bottomtexture->ScaleY : ty); bottomtexture->yScale);
} }
else else
{ {
rw_bottomtexturemid = MulScale3 (rw_bottomtexturemid - viewz, rw_bottomtexturemid = MulScale16 (rw_bottomtexturemid - viewz, bottomtexture->yScale)
bottomtexture->ScaleY ? bottomtexture->ScaleY : ty)
+ rowoffset; + rowoffset;
} }
} }
@ -1378,14 +1374,11 @@ void R_NewWall (bool needlights)
// calculate light table // calculate light table
if (needlights && (segtextured || (backsector && IsFogBoundary (frontsector, backsector)))) if (needlights && (segtextured || (backsector && IsFogBoundary (frontsector, backsector))))
{ {
lwallscale = TexMan(sidedef->midtexture) ? TexMan(sidedef->midtexture)->ScaleX : lwallscale = TexMan(sidedef->midtexture) ? TexMan(sidedef->midtexture)->xScale :
toptexture ? toptexture->ScaleX : toptexture ? toptexture->xScale :
bottomtexture ? bottomtexture->ScaleX : 0; bottomtexture ? bottomtexture->xScale : FRACUNIT;
if (lwallscale == 0)
{ PrepWall (swall, lwall, sidedef->TexelLength*lwallscale);
lwallscale = tx;
}
PrepWall (swall, lwall, (sidedef->TexelLength*lwallscale) << (FRACBITS-3));
if (!fixedcolormap) if (!fixedcolormap)
{ {
@ -1588,8 +1581,7 @@ void R_StoreWallRange (int start, int stop)
lwal = (fixed_t *)(openings + ds_p->maskedtexturecol); lwal = (fixed_t *)(openings + ds_p->maskedtexturecol);
swal = (fixed_t *)(openings + ds_p->swall); swal = (fixed_t *)(openings + ds_p->swall);
int scaley = TexMan(sidedef->midtexture)->ScaleY ? int scaley = TexMan(sidedef->midtexture)->yScale;
TexMan(sidedef->midtexture)->ScaleY : ty;
int xoffset = rw_offset; int xoffset = rw_offset;
for (i = start; i < stop; i++) for (i = start; i < stop; i++)
{ {
@ -1597,8 +1589,8 @@ void R_StoreWallRange (int start, int stop)
*swal++ = swall[i]; *swal++ = swall[i];
} }
fixed_t istart = MulScale5 (*((fixed_t *)(openings + ds_p->swall)), scaley); fixed_t istart = MulScale18 (*((fixed_t *)(openings + ds_p->swall)), scaley);
fixed_t iend = MulScale5 (*(swal - 1), scaley); fixed_t iend = MulScale18 (*(swal - 1), scaley);
if (istart < 3 && istart >= 0) istart = 3; if (istart < 3 && istart >= 0) istart = 3;
if (istart > -3 && istart < 0) istart = -3; if (istart > -3 && istart < 0) istart = -3;

View file

@ -86,7 +86,7 @@ void R_InitSkyMap ()
} }
fskyheight = skytex1->GetHeight() << FRACBITS; fskyheight = skytex1->GetHeight() << FRACBITS;
if (DivScale3 (fskyheight, skytex1->ScaleY ? skytex1->ScaleY : 8) <= (128 << FRACBITS)) if (skytex1->GetScaledHeight() <= 128)
{ {
skytexturemid = r_Yaspect/2*FRACUNIT; skytexturemid = r_Yaspect/2*FRACUNIT;
skystretch = (r_stretchsky skystretch = (r_stretchsky
@ -95,7 +95,7 @@ void R_InitSkyMap ()
} }
else else
{ {
skytexturemid = MulScale3 (199<<FRACBITS, skytex1->ScaleY ? skytex1->ScaleY : 8); skytexturemid = 199 * skytex1->yScale;
skystretch = 0; skystretch = 0;
} }
skyheight = fskyheight << skystretch; skyheight = fskyheight << skystretch;

View file

@ -1302,8 +1302,8 @@ void R_ProjectSprite (AActor *thing, int fakeside)
} }
// [RH] Added scaling // [RH] Added scaling
gzt = fz + MulScale3(thing->scaleY, tex->TopOffset * tex->ScaleX); gzt = fz + MulScale16(thing->scaleY, tex->TopOffset * tex->yScale);
gzb = fz + MulScale3(thing->scaleY, (tex->TopOffset - tex->GetHeight()) * tex->ScaleY); gzb = fz + MulScale16(thing->scaleY, (tex->TopOffset - tex->GetHeight()) * tex->yScale);
// [RH] Reject sprites that are off the top or bottom of the screen // [RH] Reject sprites that are off the top or bottom of the screen
if (MulScale12 (globaluclip, tz) > viewz - gzb || if (MulScale12 (globaluclip, tz) > viewz - gzb ||
@ -1319,7 +1319,7 @@ void R_ProjectSprite (AActor *thing, int fakeside)
} }
// calculate edges of the shape // 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; tx -= (flip ? (tex->GetWidth() - tex->LeftOffset - 1) : tex->LeftOffset) * thingxscalemul;
x1 = centerx + MulScale32 (tx, xscale); x1 = centerx + MulScale32 (tx, xscale);
@ -1335,7 +1335,7 @@ void R_ProjectSprite (AActor *thing, int fakeside)
if (x2 < WindowLeft || x2 <= x1) if (x2 < WindowLeft || x2 <= x1)
return; return;
xscale = MulScale19 (thing->scaleX, xscale * tex->ScaleX); xscale = FixedMul(FixedMul(thing->scaleX, xscale), tex->xScale);
iscale = (tex->GetWidth() << FRACBITS) / (x2 - x1); iscale = (tex->GetWidth() << FRACBITS) / (x2 - x1);
x2--; x2--;
@ -1382,16 +1382,16 @@ void R_ProjectSprite (AActor *thing, int fakeside)
vis->RenderStyle = thing->RenderStyle; vis->RenderStyle = thing->RenderStyle;
vis->AlphaColor = thing->alphacolor; vis->AlphaColor = thing->alphacolor;
vis->xscale = xscale; 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->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->cx = tx2; // signed math makes it 13.19
vis->gx = fx; vis->gx = fx;
vis->gy = fy; vis->gy = fy;
vis->gz = gzb; // [RH] use gzb, not thing->z vis->gz = gzb; // [RH] use gzb, not thing->z
vis->gzt = gzt; // killough 3/27/98 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) - 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->x1 = x1 < WindowLeft ? WindowLeft : x1;
vis->x2 = x2 > WindowRight ? WindowRight : x2; vis->x2 = x2 > WindowRight ? WindowRight : x2;
vis->Translation = thing->Translation; // [RH] thing translation table 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->floorclip = 0;
vis->texturemid = MulScale3((BASEYCENTER<<FRACBITS) - sy, tex->ScaleY) + (tex->TopOffset << FRACBITS); vis->texturemid = MulScale16((BASEYCENTER<<FRACBITS) - sy, tex->yScale) + (tex->TopOffset << FRACBITS);
if (camera->player && (RenderTarget != screen || 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->x1 = x1 < 0 ? 0 : x1;
vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2;
vis->xscale = DivScale3(pspritexscale, tex->ScaleX); vis->xscale = DivScale16(pspritexscale, tex->xScale);
vis->yscale = DivScale3(pspriteyscale, tex->ScaleY); vis->yscale = DivScale16(pspriteyscale, tex->yScale);
vis->Translation = 0; // [RH] Use default colors vis->Translation = 0; // [RH] Use default colors
vis->pic = tex; vis->pic = tex;
if (flip) if (flip)
{ {
vis->xiscale = -MulScale3(pspritexiscale, tex->ScaleX); vis->xiscale = -MulScale16(pspritexiscale, tex->xScale);
vis->startfrac = (tex->GetWidth() << FRACBITS) - 1; vis->startfrac = (tex->GetWidth() << FRACBITS) - 1;
} }
else else
{ {
vis->xiscale = MulScale3(pspritexiscale, tex->ScaleX); vis->xiscale = MulScale16(pspritexiscale, tex->xScale);
vis->startfrac = 0; vis->startfrac = 0;
} }

View file

@ -97,14 +97,8 @@ FMultiPatchTexture::FMultiPatchTexture (const void *texdef, FPatchLookup *patchl
CalcBitSize (); CalcBitSize ();
// [RH] Special for beta 29: Values of 0 will use the tx/ty cvars xScale = mtexture.d->ScaleX ? mtexture.d->ScaleX*(FRACUNIT/8) : FRACUNIT;
// to determine scaling instead of defaulting to 8. I will likely yScale = mtexture.d->ScaleY ? mtexture.d->ScaleY*(FRACUNIT/8) : FRACUNIT;
// 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;
if (mtexture.d->Flags & MAPTEXF_WORLDPANNING) if (mtexture.d->Flags & MAPTEXF_WORLDPANNING)
{ {

View file

@ -96,12 +96,12 @@ FTexture * FTexture::CreateTexture (int lumpnum, int usetype)
// Auto-scale flats with dimensions 128x128 and 256x256 // Auto-scale flats with dimensions 128x128 and 256x256
if (w==128 && h==128) if (w==128 && h==128)
{ {
tex->ScaleX = tex->ScaleY = 16; tex->xScale = tex->yScale = 2*FRACUNIT;
tex->bWorldPanning = true; tex->bWorldPanning = true;
} }
else if (w==256 && h==256) else if (w==256 && h==256)
{ {
tex->ScaleX = tex->ScaleY = 32; tex->xScale = tex->yScale = 4*FRACUNIT;
tex->bWorldPanning = true; tex->bWorldPanning = true;
} }
} }
@ -114,7 +114,7 @@ FTexture * FTexture::CreateTexture (int lumpnum, int usetype)
FTexture::FTexture () FTexture::FTexture ()
: LeftOffset(0), TopOffset(0), : 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), UseType(TEX_Any), bNoDecals(false), bNoRemap0(false), bWorldPanning(false),
bMasked(true), bAlphaTexture(false), bHasCanvas(false), bWarped(0), bIsPatch(false), bMasked(true), bAlphaTexture(false), bHasCanvas(false), bWarped(0), bIsPatch(false),
Rotations(0xFFFF), Width(0), Height(0), WidthMask(0) Rotations(0xFFFF), Width(0), Height(0), WidthMask(0)

View file

@ -42,15 +42,7 @@
FWarpTexture::FWarpTexture (FTexture *source) FWarpTexture::FWarpTexture (FTexture *source)
: SourcePic (source), Pixels (0), Spans (0), GenTime (0) : SourcePic (source), Pixels (0), Spans (0), GenTime (0)
{ {
Width = source->GetWidth (); CopySize(source);
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;
bNoDecals = source->bNoDecals; bNoDecals = source->bNoDecals;
Rotations = source->Rotations; Rotations = source->Rotations;
bWarped = 1; bWarped = 1;

View file

@ -1042,15 +1042,7 @@ FFontChar1::FFontChar1 (int sourcelump, const BYTE *sourceremap)
Name[0] = 0; // Make this texture unnamed Name[0] = 0; // Make this texture unnamed
// now copy all the properties from the base texture // now copy all the properties from the base texture
Width = BaseTexture->GetWidth(); CopySize(BaseTexture);
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;
Pixels = NULL; Pixels = NULL;
} }