- floatified texture scale values.

This commit is contained in:
Christoph Oelckers 2016-03-26 13:37:44 +01:00
parent dabed04d2a
commit 0c39bdd04c
11 changed files with 74 additions and 71 deletions

View file

@ -2722,7 +2722,8 @@ void P_PredictionLerpReset()
bool P_LerpCalculate(PredictPos from, PredictPos to, PredictPos &result, float scale) bool P_LerpCalculate(PredictPos from, PredictPos to, PredictPos &result, float scale)
{ {
DVector3 vecFrom(FIXED2DBL(from.x), FIXED2DBL(from.y), FIXED2DBL(from.z)); //DVector2 pfrom = Displacements.getOffset(from.portalgroup, to.portalgroup);
DVector3 vecFrom(FIXED2DBL(from.x) /* + pfrom.X*/, FIXED2DBL(from.y) /*+ pfrom.Y*/, FIXED2DBL(from.z));
DVector3 vecTo(FIXED2DBL(to.x), FIXED2DBL(to.y), FIXED2DBL(to.z)); DVector3 vecTo(FIXED2DBL(to.x), FIXED2DBL(to.y), FIXED2DBL(to.z));
DVector3 vecResult; DVector3 vecResult;
vecResult = vecTo - vecFrom; vecResult = vecTo - vecFrom;
@ -2730,9 +2731,11 @@ bool P_LerpCalculate(PredictPos from, PredictPos to, PredictPos &result, float s
vecResult = vecResult + vecFrom; vecResult = vecResult + vecFrom;
DVector3 delta = vecResult - vecTo; DVector3 delta = vecResult - vecTo;
//result.pos = pmo->Vec3Offset(FLOAT2FIXED(vecResult.X) - to.pos.x, FLOAT2FIXED(vecResult.Y) - to.pos.y, FLOAT2FIXED(vecResult.Z) - to.pos.z);
result.x = FLOAT2FIXED(vecResult.X); result.x = FLOAT2FIXED(vecResult.X);
result.y = FLOAT2FIXED(vecResult.Y); result.y = FLOAT2FIXED(vecResult.Y);
result.z = FLOAT2FIXED(vecResult.Z); result.z = FLOAT2FIXED(vecResult.Z);
//result.portalgroup = P_PointInSector(result.pos.x, result.pos.y)->PortalGroup;
// As a fail safe, assume extrapolation is the threshold. // As a fail safe, assume extrapolation is the threshold.
return (delta.LengthSquared() > cl_predict_lerpthreshold && scale <= 1.00f); return (delta.LengthSquared() > cl_predict_lerpthreshold && scale <= 1.00f);
@ -2844,10 +2847,10 @@ void P_PredictPlayer (player_t *player)
// Aditional Debug information // Aditional Debug information
if (developer && DoLerp) if (developer && DoLerp)
{ {
DPrintf("Lerp! Ltic (%d) && Ptic (%d) | Lx (%d) && Px (%d) | Ly (%d) && Py (%d)\n", DPrintf("Lerp! Ltic (%d) && Ptic (%d) | Lx (%d) && Px (%f) | Ly (%d) && Py (%f)\n",
PredictionLast.gametic, i, PredictionLast.gametic, i,
(PredictionLast.x >> 16), (player->mo->_f_X() >> 16), (PredictionLast.x >> 16), (player->mo->X()),
(PredictionLast.y >> 16), (player->mo->_f_Y() >> 16)); (PredictionLast.y >> 16), (player->mo->Y()));
} }
} }
} }
@ -2868,11 +2871,12 @@ void P_PredictPlayer (player_t *player)
PredictionLast.x = player->mo->_f_X(); PredictionLast.x = player->mo->_f_X();
PredictionLast.y = player->mo->_f_Y(); PredictionLast.y = player->mo->_f_Y();
PredictionLast.z = player->mo->_f_Z(); PredictionLast.z = player->mo->_f_Z();
//PredictionLast.portalgroup = player->mo->Sector->PortalGroup;
if (PredictionLerptics > 0) if (PredictionLerptics > 0)
{ {
if (PredictionLerpFrom.gametic > 0 && if (PredictionLerpFrom.gametic > 0 &&
P_LerpCalculate(PredictionLerpFrom, PredictionLast, PredictionLerpResult, (float)PredictionLerptics * cl_predict_lerpscale)) P_LerpCalculate(/*player->mo,*/ PredictionLerpFrom, PredictionLast, PredictionLerpResult, (float)PredictionLerptics * cl_predict_lerpscale))
{ {
PredictionLerptics++; PredictionLerptics++;
player->mo->SetXYZ(PredictionLerpResult.x, PredictionLerpResult.y, PredictionLerpResult.z); player->mo->SetXYZ(PredictionLerpResult.x, PredictionLerpResult.y, PredictionLerpResult.z);

View file

@ -957,7 +957,7 @@ static void R_DrawSky (visplane_t *pl)
rw_pic = frontskytex; rw_pic = frontskytex;
rw_offset = 0; rw_offset = 0;
frontyScale = rw_pic->yScale; frontyScale = FLOAT2FIXED(rw_pic->Scale.Y);
dc_texturemid = MulScale16 (skymid, frontyScale); dc_texturemid = MulScale16 (skymid, frontyScale);
if (1 << frontskytex->HeightBits == frontskytex->GetHeight()) if (1 << frontskytex->HeightBits == frontskytex->GetHeight())
@ -1003,6 +1003,7 @@ static void R_DrawSkyStriped (visplane_t *pl)
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);
fixed_t yScale = FLOAT2FIXED(rw_pic->Scale.Y);
while (yl < viewheight) while (yl < viewheight)
{ {
@ -1015,7 +1016,7 @@ static void R_DrawSkyStriped (visplane_t *pl)
{ {
lastskycol[x] = 0xffffffff; lastskycol[x] = 0xffffffff;
} }
wallscan (pl->left, pl->right, top, bot, swall, lwall, rw_pic->yScale, wallscan (pl->left, pl->right, top, bot, swall, lwall, yScale,
backskytex == NULL ? R_GetOneSkyColumn : R_GetTwoSkyColumns); backskytex == NULL ? R_GetOneSkyColumn : R_GetTwoSkyColumns);
yl = yh; yl = yh;
yh += drawheight; yh += drawheight;
@ -1136,8 +1137,8 @@ void R_DrawSinglePlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
masked = false; masked = false;
} }
R_SetupSpanBits(tex); R_SetupSpanBits(tex);
pl->xscale = MulScale16 (pl->xscale, tex->xScale); pl->xscale = fixed_t(pl->xscale * tex->Scale.X);
pl->yscale = MulScale16 (pl->yscale, tex->yScale); pl->yscale = fixed_t(pl->yscale * tex->Scale.Y);
ds_source = tex->GetPixels (); ds_source = tex->GetPixels ();
basecolormap = pl->colormap; basecolormap = pl->colormap;
@ -1476,7 +1477,8 @@ void R_DrawSkyPlane (visplane_t *pl)
// allow old sky textures to be used. // allow old sky textures to be used.
skyflip = l->args[2] ? 0u : ~0u; skyflip = l->args[2] ? 0u : ~0u;
frontcyl = MAX(frontskytex->GetWidth(), frontskytex->xScale >> (16 - 10)); int frontxscale = int(frontskytex->Scale.X * 1024);
frontcyl = MAX(frontskytex->GetWidth(), frontxscale);
if (skystretch) if (skystretch)
{ {
skymid = Scale(skymid, frontskytex->GetScaledHeight(), SKYSTRETCH_HEIGHT); skymid = Scale(skymid, frontskytex->GetScaledHeight(), SKYSTRETCH_HEIGHT);

View file

@ -601,8 +601,8 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover)
scaledside = rover->master->sidedef[0]; scaledside = rover->master->sidedef[0];
scaledpart = side_t::mid; scaledpart = side_t::mid;
} }
xscale = FixedMul(rw_pic->xScale, scaledside->GetTextureXScale(scaledpart)); xscale = fixed_t(rw_pic->Scale.X * scaledside->GetTextureXScale(scaledpart));
yscale = FixedMul(rw_pic->yScale, scaledside->GetTextureYScale(scaledpart)); yscale = fixed_t(rw_pic->Scale.Y * scaledside->GetTextureYScale(scaledpart));
fixed_t rowoffset = curline->sidedef->GetTextureYOffset(side_t::mid) + rover->master->sidedef[0]->GetTextureYOffset(side_t::mid); fixed_t rowoffset = curline->sidedef->GetTextureYOffset(side_t::mid) + rover->master->sidedef[0]->GetTextureYOffset(side_t::mid);
dc_texturemid = rover->model->GetPlaneTexZ(sector_t::ceiling); dc_texturemid = rover->model->GetPlaneTexZ(sector_t::ceiling);
@ -1861,8 +1861,8 @@ void R_RenderSegLoop ()
{ {
dc_texturemid = rw_midtexturemid; dc_texturemid = rw_midtexturemid;
rw_pic = midtexture; rw_pic = midtexture;
xscale = FixedMul(rw_pic->xScale, rw_midtexturescalex); xscale = fixed_t(rw_pic->Scale.X * rw_midtexturescalex);
yscale = FixedMul(rw_pic->yScale, rw_midtexturescaley); yscale = fixed_t(rw_pic->Scale.Y * rw_midtexturescaley);
if (xscale != lwallscale) if (xscale != lwallscale)
{ {
PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2); PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2);
@ -1904,8 +1904,8 @@ void R_RenderSegLoop ()
{ {
dc_texturemid = rw_toptexturemid; dc_texturemid = rw_toptexturemid;
rw_pic = toptexture; rw_pic = toptexture;
xscale = FixedMul(rw_pic->xScale, rw_toptexturescalex); xscale = fixed_t(rw_pic->Scale.X * rw_toptexturescalex);
yscale = FixedMul(rw_pic->yScale, rw_toptexturescaley); yscale = fixed_t(rw_pic->Scale.Y * rw_toptexturescaley);
if (xscale != lwallscale) if (xscale != lwallscale)
{ {
PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2); PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2);
@ -1950,8 +1950,8 @@ void R_RenderSegLoop ()
{ {
dc_texturemid = rw_bottomtexturemid; dc_texturemid = rw_bottomtexturemid;
rw_pic = bottomtexture; rw_pic = bottomtexture;
xscale = FixedMul(rw_pic->xScale, rw_bottomtexturescalex); xscale = fixed_t(rw_pic->Scale.X * rw_bottomtexturescalex);
yscale = FixedMul(rw_pic->yScale, rw_bottomtexturescaley); yscale = fixed_t(rw_pic->Scale.Y * rw_bottomtexturescaley);
if (xscale != lwallscale) if (xscale != lwallscale)
{ {
PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2); PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2);
@ -2021,7 +2021,7 @@ void R_NewWall (bool needlights)
rowoffset = sidedef->GetTextureYOffset(side_t::mid); rowoffset = sidedef->GetTextureYOffset(side_t::mid);
rw_midtexturescalex = sidedef->GetTextureXScale(side_t::mid); rw_midtexturescalex = sidedef->GetTextureXScale(side_t::mid);
rw_midtexturescaley = sidedef->GetTextureYScale(side_t::mid); rw_midtexturescaley = sidedef->GetTextureYScale(side_t::mid);
yrepeat = FixedMul(midtexture->yScale, rw_midtexturescaley); yrepeat = fixed_t(midtexture->Scale.Y * rw_midtexturescaley);
if (yrepeat >= 0) if (yrepeat >= 0)
{ // normal orientation { // normal orientation
if (linedef->flags & ML_DONTPEGBOTTOM) if (linedef->flags & ML_DONTPEGBOTTOM)
@ -2176,7 +2176,7 @@ void R_NewWall (bool needlights)
rowoffset = sidedef->GetTextureYOffset(side_t::top); rowoffset = sidedef->GetTextureYOffset(side_t::top);
rw_toptexturescalex = sidedef->GetTextureXScale(side_t::top); rw_toptexturescalex = sidedef->GetTextureXScale(side_t::top);
rw_toptexturescaley = sidedef->GetTextureYScale(side_t::top); rw_toptexturescaley = sidedef->GetTextureYScale(side_t::top);
yrepeat = FixedMul(toptexture->yScale, rw_toptexturescaley); yrepeat = fixed_t(toptexture->Scale.Y * rw_toptexturescaley);
if (yrepeat >= 0) if (yrepeat >= 0)
{ // normal orientation { // normal orientation
if (linedef->flags & ML_DONTPEGTOP) if (linedef->flags & ML_DONTPEGTOP)
@ -2221,7 +2221,7 @@ void R_NewWall (bool needlights)
rowoffset = sidedef->GetTextureYOffset(side_t::bottom); rowoffset = sidedef->GetTextureYOffset(side_t::bottom);
rw_bottomtexturescalex = sidedef->GetTextureXScale(side_t::bottom); rw_bottomtexturescalex = sidedef->GetTextureXScale(side_t::bottom);
rw_bottomtexturescaley = sidedef->GetTextureYScale(side_t::bottom); rw_bottomtexturescaley = sidedef->GetTextureYScale(side_t::bottom);
yrepeat = FixedMul(bottomtexture->yScale, rw_bottomtexturescaley); yrepeat = fixed_t(bottomtexture->Scale.Y * rw_bottomtexturescaley);
if (yrepeat >= 0) if (yrepeat >= 0)
{ // normal orientation { // normal orientation
if (linedef->flags & ML_DONTPEGBOTTOM) if (linedef->flags & ML_DONTPEGBOTTOM)
@ -2292,9 +2292,9 @@ void R_NewWall (bool needlights)
if (needlights && (segtextured || (backsector && IsFogBoundary(frontsector, backsector)))) if (needlights && (segtextured || (backsector && IsFogBoundary(frontsector, backsector))))
{ {
lwallscale = lwallscale =
midtex ? FixedMul(midtex->xScale, sidedef->GetTextureXScale(side_t::mid)) : midtex ? int(midtex->Scale.X * sidedef->GetTextureXScale(side_t::mid)) :
toptexture ? FixedMul(toptexture->xScale, sidedef->GetTextureXScale(side_t::top)) : toptexture ? int(toptexture->Scale.X * sidedef->GetTextureXScale(side_t::top)) :
bottomtexture ? FixedMul(bottomtexture->xScale, sidedef->GetTextureXScale(side_t::bottom)) : bottomtexture ? int(bottomtexture->Scale.X * sidedef->GetTextureXScale(side_t::bottom)) :
FRACUNIT; FRACUNIT;
PrepWall (swall, lwall, sidedef->TexelLength * lwallscale, WallC.sx1, WallC.sx2); PrepWall (swall, lwall, sidedef->TexelLength * lwallscale, WallC.sx1, WallC.sx2);
@ -2507,7 +2507,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);
FTexture *pic = TexMan(sidedef->GetTexture(side_t::mid), true); FTexture *pic = TexMan(sidedef->GetTexture(side_t::mid), true);
fixed_t yrepeat = FixedMul(pic->yScale, sidedef->GetTextureYScale(side_t::mid)); fixed_t yrepeat = int(pic->Scale.X * sidedef->GetTextureYScale(side_t::mid));
fixed_t xoffset = sidedef->GetTextureXOffset(side_t::mid); fixed_t xoffset = sidedef->GetTextureXOffset(side_t::mid);
if (pic->bWorldPanning) if (pic->bWorldPanning)

View file

@ -107,7 +107,7 @@ void R_InitSkyMap ()
} }
else if (skyheight > 200) else if (skyheight > 200)
{ {
skytexturemid = FixedMul((200 - skyheight) << FRACBITS, skytex1->yScale); skytexturemid = FLOAT2FIXED((200 - skyheight) * skytex1->Scale.Y);
} }
if (viewwidth != 0 && viewheight != 0) if (viewwidth != 0 && viewheight != 0)
@ -131,8 +131,8 @@ void R_InitSkyMap ()
// giving a total sky width of 1024 pixels. So if the sky texture is no wider than 1024, // giving a total sky width of 1024 pixels. So if the sky texture is no wider than 1024,
// we map it to a cylinder with circumfrence 1024. For larger ones, we use the width of // we map it to a cylinder with circumfrence 1024. For larger ones, we use the width of
// the texture as the cylinder's circumfrence. // the texture as the cylinder's circumfrence.
sky1cyl = MAX(skytex1->GetWidth(), skytex1->xScale >> (16 - 10)); sky1cyl = MAX(skytex1->GetWidth(), fixed_t(skytex1->Scale.X * 1024));
sky2cyl = MAX(skytex2->GetWidth(), skytex2->xScale >> (16 - 10)); sky2cyl = MAX(skytex2->GetWidth(), fixed_t(skytex2->Scale.Y * 1024));
} }

View file

@ -969,7 +969,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
renderflags ^= MirrorFlags & RF_XFLIP; renderflags ^= MirrorFlags & RF_XFLIP;
// calculate edges of the shape // calculate edges of the shape
const fixed_t thingxscalemul = DivScale16(spritescaleX, tex->xScale); const fixed_t thingxscalemul = fixed_t(spritescaleX / tex->Scale.X);
tx -= ((renderflags & RF_XFLIP) ? (tex->GetWidth() - tex->LeftOffset - 1) : tex->LeftOffset) * thingxscalemul; tx -= ((renderflags & RF_XFLIP) ? (tex->GetWidth() - tex->LeftOffset - 1) : tex->LeftOffset) * thingxscalemul;
x1 = centerx + MulScale32 (tx, xscale); x1 = centerx + MulScale32 (tx, xscale);
@ -985,10 +985,10 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
if ((x2 < WindowLeft || x2 <= x1)) if ((x2 < WindowLeft || x2 <= x1))
return; return;
xscale = FixedDiv(FixedMul(spritescaleX, xscale), tex->xScale); xscale = fixed_t(FixedMul(spritescaleX, xscale) / tex->Scale.X);
iscale = (tex->GetWidth() << FRACBITS) / (x2 - x1); iscale = (tex->GetWidth() << FRACBITS) / (x2 - x1);
fixed_t yscale = SafeDivScale16(spritescaleY, tex->yScale); fixed_t yscale = fixed_t(spritescaleY / tex->Scale.Y);
// store information in a vissprite // store information in a vissprite
vis = R_NewVisSprite(); vis = R_NewVisSprite();
@ -1335,7 +1335,7 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_
vis->floorclip = 0; vis->floorclip = 0;
vis->texturemid = MulScale16((BASEYCENTER<<FRACBITS) - sy, tex->yScale) + (tex->TopOffset << FRACBITS); vis->texturemid = int(((BASEYCENTER<<FRACBITS) - sy) * tex->Scale.Y) + (tex->TopOffset << FRACBITS);
if (camera->player && (RenderTarget != screen || if (camera->player && (RenderTarget != screen ||
@ -1365,20 +1365,20 @@ 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 : x2; vis->x2 = x2 >= viewwidth ? viewwidth : x2;
vis->xscale = DivScale16(pspritexscale, tex->xScale); vis->xscale = fixed_t(pspritexscale / tex->Scale.X);
vis->yscale = DivScale16(pspriteyscale, tex->yScale); vis->yscale = fixed_t(pspriteyscale / tex->Scale.Y);
vis->Translation = 0; // [RH] Use default colors vis->Translation = 0; // [RH] Use default colors
vis->pic = tex; vis->pic = tex;
vis->ColormapNum = 0; vis->ColormapNum = 0;
if (flip) if (flip)
{ {
vis->xiscale = -MulScale16(pspritexiscale, tex->xScale); vis->xiscale = -int(pspritexiscale * tex->Scale.X);
vis->startfrac = (tex->GetWidth() << FRACBITS) - 1; vis->startfrac = (tex->GetWidth() << FRACBITS) - 1;
} }
else else
{ {
vis->xiscale = MulScale16(pspritexiscale, tex->xScale); vis->xiscale = int(pspritexiscale * tex->Scale.X);
vis->startfrac = 0; vis->startfrac = 0;
} }

View file

@ -246,8 +246,8 @@ FMultiPatchTexture::FMultiPatchTexture (const void *texdef, FPatchLookup *patchl
Name = (char *)mtexture.d->name; Name = (char *)mtexture.d->name;
CalcBitSize (); CalcBitSize ();
xScale = mtexture.d->ScaleX ? mtexture.d->ScaleX*(FRACUNIT/8) : FRACUNIT; Scale.X = mtexture.d->ScaleX ? mtexture.d->ScaleX / 8. : 1.;
yScale = mtexture.d->ScaleY ? mtexture.d->ScaleY*(FRACUNIT/8) : FRACUNIT; Scale.Y = mtexture.d->ScaleY ? mtexture.d->ScaleY / 8. : 1.;
if (mtexture.d->Flags & MAPTEXF_WORLDPANNING) if (mtexture.d->Flags & MAPTEXF_WORLDPANNING)
{ {
@ -1243,14 +1243,14 @@ FMultiPatchTexture::FMultiPatchTexture (FScanner &sc, int usetype)
if (sc.Compare("XScale")) if (sc.Compare("XScale"))
{ {
sc.MustGetFloat(); sc.MustGetFloat();
xScale = FLOAT2FIXED(sc.Float); Scale.X = sc.Float;
if (xScale == 0) sc.ScriptError("Texture %s is defined with null x-scale\n", Name.GetChars()); if (Scale.X == 0) sc.ScriptError("Texture %s is defined with null x-scale\n", Name.GetChars());
} }
else if (sc.Compare("YScale")) else if (sc.Compare("YScale"))
{ {
sc.MustGetFloat(); sc.MustGetFloat();
yScale = FLOAT2FIXED(sc.Float); Scale.Y = sc.Float;
if (yScale == 0) sc.ScriptError("Texture %s is defined with null y-scale\n", Name.GetChars()); if (Scale.Y == 0) sc.ScriptError("Texture %s is defined with null y-scale\n", Name.GetChars());
} }
else if (sc.Compare("WorldPanning")) else if (sc.Compare("WorldPanning"))
{ {

View file

@ -118,12 +118,12 @@ FTexture * FTexture::CreateTexture (int lumpnum, int usetype)
// Now we're stuck with this stupid behaviour. // Now we're stuck with this stupid behaviour.
if (w==128 && h==128) if (w==128 && h==128)
{ {
tex->xScale = tex->yScale = 2*FRACUNIT; tex->Scale.X = tex->Scale.Y = 2;
tex->bWorldPanning = true; tex->bWorldPanning = true;
} }
else if (w==256 && h==256) else if (w==256 && h==256)
{ {
tex->xScale = tex->yScale = 4*FRACUNIT; tex->Scale.X = tex->Scale.Y = 4;
tex->bWorldPanning = true; tex->bWorldPanning = true;
} }
} }
@ -147,7 +147,7 @@ FTexture * FTexture::CreateTexture (const char *name, int lumpnum, int usetype)
FTexture::FTexture (const char *name, int lumpnum) FTexture::FTexture (const char *name, int lumpnum)
: LeftOffset(0), TopOffset(0), : LeftOffset(0), TopOffset(0),
WidthBits(0), HeightBits(0), xScale(FRACUNIT), yScale(FRACUNIT), SourceLump(lumpnum), WidthBits(0), HeightBits(0), Scale(1,1), SourceLump(lumpnum),
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), bComplex(false), bMultiPatch(false), bKeepAround(false), bMasked(true), bAlphaTexture(false), bHasCanvas(false), bWarped(0), bComplex(false), bMultiPatch(false), bKeepAround(false),
Rotations(0xFFFF), SkyOffset(0), Width(0), Height(0), WidthMask(0), Native(NULL) Rotations(0xFFFF), SkyOffset(0), Width(0), Height(0), WidthMask(0), Native(NULL)
@ -562,11 +562,11 @@ FTexture *FTexture::GetRawTexture()
void FTexture::SetScaledSize(int fitwidth, int fitheight) void FTexture::SetScaledSize(int fitwidth, int fitheight)
{ {
xScale = FLOAT2FIXED(float(Width) / fitwidth); Scale.X = double(Width) / fitwidth;
yScale = FLOAT2FIXED(float(Height) / fitheight); Scale.Y =double(Height) / fitheight;
// compensate for roundoff errors // compensate for roundoff errors
if (MulScale16(xScale, fitwidth) != Width) xScale++; if (int(Scale.X * fitwidth) != Width) Scale.X += (1 / 65536.);
if (MulScale16(yScale, fitheight) != Height) yScale++; if (int(Scale.Y * fitheight) != Height) Scale.Y += (1 / 65536.);
} }

View file

@ -569,8 +569,8 @@ void FTextureManager::AddHiresTextures (int wadnum)
// 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->SetScaledSize(oldtex->GetScaledWidth(), oldtex->GetScaledHeight()); newtex->SetScaledSize(oldtex->GetScaledWidth(), oldtex->GetScaledHeight());
newtex->LeftOffset = FixedMul(oldtex->GetScaledLeftOffset(), newtex->xScale); newtex->LeftOffset = int(oldtex->GetScaledLeftOffset() * newtex->Scale.X);
newtex->TopOffset = FixedMul(oldtex->GetScaledTopOffset(), newtex->yScale); newtex->TopOffset = int(oldtex->GetScaledTopOffset() * newtex->Scale.Y);
ReplaceTexture(tlist[i], newtex, true); ReplaceTexture(tlist[i], newtex, true);
} }
} }
@ -658,8 +658,8 @@ void FTextureManager::LoadTextureDefs(int wadnum, const char *lumpname)
// 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->SetScaledSize(oldtex->GetScaledWidth(), oldtex->GetScaledHeight()); newtex->SetScaledSize(oldtex->GetScaledWidth(), oldtex->GetScaledHeight());
newtex->LeftOffset = FixedMul(oldtex->GetScaledLeftOffset(), newtex->xScale); newtex->LeftOffset = int(oldtex->GetScaledLeftOffset() * newtex->Scale.X);
newtex->TopOffset = FixedMul(oldtex->GetScaledTopOffset(), newtex->yScale); newtex->TopOffset = int(oldtex->GetScaledTopOffset() * newtex->Scale.Y);
ReplaceTexture(tlist[i], newtex, true); ReplaceTexture(tlist[i], newtex, true);
} }
} }

View file

@ -1,8 +1,7 @@
#ifndef __TEXTURES_H #ifndef __TEXTURES_H
#define __TEXTURES_H #define __TEXTURES_H
#include "doomtype.h" #include "vectors.h"
#include "m_fixed.h"
class FBitmap; class FBitmap;
struct FRemapTable; struct FRemapTable;
@ -123,8 +122,7 @@ public:
BYTE WidthBits, HeightBits; BYTE WidthBits, HeightBits;
fixed_t xScale; DVector2 Scale;
fixed_t yScale;
int SourceLump; int SourceLump;
FTextureID id; FTextureID id;
@ -203,16 +201,16 @@ public:
int GetWidth () { return Width; } int GetWidth () { return Width; }
int GetHeight () { return Height; } int GetHeight () { return Height; }
int GetScaledWidth () { int foo = (Width << 17) / xScale; return (foo >> 1) + (foo & 1); } int GetScaledWidth () { int foo = int((Width * 2) / Scale.X); return (foo >> 1) + (foo & 1); }
int GetScaledHeight () { int foo = (Height << 17) / yScale; return (foo >> 1) + (foo & 1); } int GetScaledHeight () { int foo = int((Height * 2) / Scale.Y); return (foo >> 1) + (foo & 1); }
double GetScaledWidthDouble () { return (Width * 65536.) / xScale; } double GetScaledWidthDouble () { return Width / Scale.X; }
double GetScaledHeightDouble () { return (Height * 65536.) / yScale; } double GetScaledHeightDouble () { return Height / Scale.Y; }
double GetScaleY() const { return FIXED2DBL(yScale); } double GetScaleY() const { return Scale.Y; }
int GetScaledLeftOffset () { int foo = (LeftOffset << 17) / xScale; return (foo >> 1) + (foo & 1); } int GetScaledLeftOffset () { int foo = int((LeftOffset * 2) / Scale.X); return (foo >> 1) + (foo & 1); }
int GetScaledTopOffset () { int foo = (TopOffset << 17) / yScale; return (foo >> 1) + (foo & 1); } int GetScaledTopOffset () { int foo = int((TopOffset * 2) / Scale.Y); return (foo >> 1) + (foo & 1); }
double GetScaledLeftOffsetDouble() { return (LeftOffset * 65536.) / xScale; } double GetScaledLeftOffsetDouble() { return LeftOffset / Scale.X; }
double GetScaledTopOffsetDouble() { return (TopOffset * 65536.) / yScale; } double GetScaledTopOffsetDouble() { return TopOffset / Scale.Y; }
virtual void SetFrontSkyLayer(); virtual void SetFrontSkyLayer();
@ -238,8 +236,7 @@ public:
LeftOffset = BaseTexture->LeftOffset; LeftOffset = BaseTexture->LeftOffset;
WidthBits = BaseTexture->WidthBits; WidthBits = BaseTexture->WidthBits;
HeightBits = BaseTexture->HeightBits; HeightBits = BaseTexture->HeightBits;
xScale = BaseTexture->xScale; Scale = BaseTexture->Scale;
yScale = BaseTexture->yScale;
WidthMask = (1 << WidthBits) - 1; WidthMask = (1 << WidthBits) - 1;
} }

View file

@ -1201,8 +1201,8 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints,
return; return;
} }
scalex /= FIXED2DBL(tex->xScale); scalex /= tex->Scale.X;
scaley /= FIXED2DBL(tex->yScale); scaley /= tex->Scale.Y;
// Use the CRT's functions here. // Use the CRT's functions here.
cosrot = cos(ToRadians(rotation)); cosrot = cos(ToRadians(rotation));

View file

@ -759,7 +759,7 @@ int CheckRealHeight(FTexture *tex)
} }
} }
// Scale maxy before returning it // Scale maxy before returning it
maxy = (maxy << 17) / tex->yScale; maxy = int((maxy *2) / tex->Scale.Y);
maxy = (maxy >> 1) + (maxy & 1); maxy = (maxy >> 1) + (maxy & 1);
return maxy; return maxy;
} }