- 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)
{
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 vecResult;
vecResult = vecTo - vecFrom;
@ -2730,9 +2731,11 @@ bool P_LerpCalculate(PredictPos from, PredictPos to, PredictPos &result, float s
vecResult = vecResult + vecFrom;
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.y = FLOAT2FIXED(vecResult.Y);
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.
return (delta.LengthSquared() > cl_predict_lerpthreshold && scale <= 1.00f);
@ -2844,10 +2847,10 @@ void P_PredictPlayer (player_t *player)
// Aditional Debug information
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.x >> 16), (player->mo->_f_X() >> 16),
(PredictionLast.y >> 16), (player->mo->_f_Y() >> 16));
(PredictionLast.x >> 16), (player->mo->X()),
(PredictionLast.y >> 16), (player->mo->Y()));
}
}
}
@ -2868,11 +2871,12 @@ void P_PredictPlayer (player_t *player)
PredictionLast.x = player->mo->_f_X();
PredictionLast.y = player->mo->_f_Y();
PredictionLast.z = player->mo->_f_Z();
//PredictionLast.portalgroup = player->mo->Sector->PortalGroup;
if (PredictionLerptics > 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++;
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_offset = 0;
frontyScale = rw_pic->yScale;
frontyScale = FLOAT2FIXED(rw_pic->Scale.Y);
dc_texturemid = MulScale16 (skymid, frontyScale);
if (1 << frontskytex->HeightBits == frontskytex->GetHeight())
@ -1003,6 +1003,7 @@ static void R_DrawSkyStriped (visplane_t *pl)
yl = 0;
yh = (short)MulScale32 ((frontskytex->GetHeight() << FRACBITS) - topfrac, frontyScale);
dc_texturemid = topfrac - iscale * (1-centery);
fixed_t yScale = FLOAT2FIXED(rw_pic->Scale.Y);
while (yl < viewheight)
{
@ -1015,7 +1016,7 @@ static void R_DrawSkyStriped (visplane_t *pl)
{
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);
yl = yh;
yh += drawheight;
@ -1136,8 +1137,8 @@ void R_DrawSinglePlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske
masked = false;
}
R_SetupSpanBits(tex);
pl->xscale = MulScale16 (pl->xscale, tex->xScale);
pl->yscale = MulScale16 (pl->yscale, tex->yScale);
pl->xscale = fixed_t(pl->xscale * tex->Scale.X);
pl->yscale = fixed_t(pl->yscale * tex->Scale.Y);
ds_source = tex->GetPixels ();
basecolormap = pl->colormap;
@ -1476,7 +1477,8 @@ void R_DrawSkyPlane (visplane_t *pl)
// allow old sky textures to be used.
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)
{
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];
scaledpart = side_t::mid;
}
xscale = FixedMul(rw_pic->xScale, scaledside->GetTextureXScale(scaledpart));
yscale = FixedMul(rw_pic->yScale, scaledside->GetTextureYScale(scaledpart));
xscale = fixed_t(rw_pic->Scale.X * scaledside->GetTextureXScale(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);
dc_texturemid = rover->model->GetPlaneTexZ(sector_t::ceiling);
@ -1861,8 +1861,8 @@ void R_RenderSegLoop ()
{
dc_texturemid = rw_midtexturemid;
rw_pic = midtexture;
xscale = FixedMul(rw_pic->xScale, rw_midtexturescalex);
yscale = FixedMul(rw_pic->yScale, rw_midtexturescaley);
xscale = fixed_t(rw_pic->Scale.X * rw_midtexturescalex);
yscale = fixed_t(rw_pic->Scale.Y * rw_midtexturescaley);
if (xscale != lwallscale)
{
PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2);
@ -1904,8 +1904,8 @@ void R_RenderSegLoop ()
{
dc_texturemid = rw_toptexturemid;
rw_pic = toptexture;
xscale = FixedMul(rw_pic->xScale, rw_toptexturescalex);
yscale = FixedMul(rw_pic->yScale, rw_toptexturescaley);
xscale = fixed_t(rw_pic->Scale.X * rw_toptexturescalex);
yscale = fixed_t(rw_pic->Scale.Y * rw_toptexturescaley);
if (xscale != lwallscale)
{
PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2);
@ -1950,8 +1950,8 @@ void R_RenderSegLoop ()
{
dc_texturemid = rw_bottomtexturemid;
rw_pic = bottomtexture;
xscale = FixedMul(rw_pic->xScale, rw_bottomtexturescalex);
yscale = FixedMul(rw_pic->yScale, rw_bottomtexturescaley);
xscale = fixed_t(rw_pic->Scale.X * rw_bottomtexturescalex);
yscale = fixed_t(rw_pic->Scale.Y * rw_bottomtexturescaley);
if (xscale != lwallscale)
{
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);
rw_midtexturescalex = sidedef->GetTextureXScale(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)
{ // normal orientation
if (linedef->flags & ML_DONTPEGBOTTOM)
@ -2176,7 +2176,7 @@ void R_NewWall (bool needlights)
rowoffset = sidedef->GetTextureYOffset(side_t::top);
rw_toptexturescalex = sidedef->GetTextureXScale(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)
{ // normal orientation
if (linedef->flags & ML_DONTPEGTOP)
@ -2221,7 +2221,7 @@ void R_NewWall (bool needlights)
rowoffset = sidedef->GetTextureYOffset(side_t::bottom);
rw_bottomtexturescalex = sidedef->GetTextureXScale(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)
{ // normal orientation
if (linedef->flags & ML_DONTPEGBOTTOM)
@ -2292,9 +2292,9 @@ void R_NewWall (bool needlights)
if (needlights && (segtextured || (backsector && IsFogBoundary(frontsector, backsector))))
{
lwallscale =
midtex ? FixedMul(midtex->xScale, sidedef->GetTextureXScale(side_t::mid)) :
toptexture ? FixedMul(toptexture->xScale, sidedef->GetTextureXScale(side_t::top)) :
bottomtexture ? FixedMul(bottomtexture->xScale, sidedef->GetTextureXScale(side_t::bottom)) :
midtex ? int(midtex->Scale.X * sidedef->GetTextureXScale(side_t::mid)) :
toptexture ? int(toptexture->Scale.X * sidedef->GetTextureXScale(side_t::top)) :
bottomtexture ? int(bottomtexture->Scale.X * sidedef->GetTextureXScale(side_t::bottom)) :
FRACUNIT;
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);
swal = (fixed_t *)(openings + ds_p->swall);
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);
if (pic->bWorldPanning)

View File

@ -107,7 +107,7 @@ void R_InitSkyMap ()
}
else if (skyheight > 200)
{
skytexturemid = FixedMul((200 - skyheight) << FRACBITS, skytex1->yScale);
skytexturemid = FLOAT2FIXED((200 - skyheight) * skytex1->Scale.Y);
}
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,
// we map it to a cylinder with circumfrence 1024. For larger ones, we use the width of
// the texture as the cylinder's circumfrence.
sky1cyl = MAX(skytex1->GetWidth(), skytex1->xScale >> (16 - 10));
sky2cyl = MAX(skytex2->GetWidth(), skytex2->xScale >> (16 - 10));
sky1cyl = MAX(skytex1->GetWidth(), fixed_t(skytex1->Scale.X * 1024));
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;
// 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;
x1 = centerx + MulScale32 (tx, xscale);
@ -985,10 +985,10 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor
if ((x2 < WindowLeft || x2 <= x1))
return;
xscale = FixedDiv(FixedMul(spritescaleX, xscale), tex->xScale);
xscale = fixed_t(FixedMul(spritescaleX, xscale) / tex->Scale.X);
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
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->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 ||
@ -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->x2 = x2 >= viewwidth ? viewwidth : x2;
vis->xscale = DivScale16(pspritexscale, tex->xScale);
vis->yscale = DivScale16(pspriteyscale, tex->yScale);
vis->xscale = fixed_t(pspritexscale / tex->Scale.X);
vis->yscale = fixed_t(pspriteyscale / tex->Scale.Y);
vis->Translation = 0; // [RH] Use default colors
vis->pic = tex;
vis->ColormapNum = 0;
if (flip)
{
vis->xiscale = -MulScale16(pspritexiscale, tex->xScale);
vis->xiscale = -int(pspritexiscale * tex->Scale.X);
vis->startfrac = (tex->GetWidth() << FRACBITS) - 1;
}
else
{
vis->xiscale = MulScale16(pspritexiscale, tex->xScale);
vis->xiscale = int(pspritexiscale * tex->Scale.X);
vis->startfrac = 0;
}

View File

@ -246,8 +246,8 @@ FMultiPatchTexture::FMultiPatchTexture (const void *texdef, FPatchLookup *patchl
Name = (char *)mtexture.d->name;
CalcBitSize ();
xScale = mtexture.d->ScaleX ? mtexture.d->ScaleX*(FRACUNIT/8) : FRACUNIT;
yScale = mtexture.d->ScaleY ? mtexture.d->ScaleY*(FRACUNIT/8) : FRACUNIT;
Scale.X = mtexture.d->ScaleX ? mtexture.d->ScaleX / 8. : 1.;
Scale.Y = mtexture.d->ScaleY ? mtexture.d->ScaleY / 8. : 1.;
if (mtexture.d->Flags & MAPTEXF_WORLDPANNING)
{
@ -1243,14 +1243,14 @@ FMultiPatchTexture::FMultiPatchTexture (FScanner &sc, int usetype)
if (sc.Compare("XScale"))
{
sc.MustGetFloat();
xScale = FLOAT2FIXED(sc.Float);
if (xScale == 0) sc.ScriptError("Texture %s is defined with null x-scale\n", Name.GetChars());
Scale.X = sc.Float;
if (Scale.X == 0) sc.ScriptError("Texture %s is defined with null x-scale\n", Name.GetChars());
}
else if (sc.Compare("YScale"))
{
sc.MustGetFloat();
yScale = FLOAT2FIXED(sc.Float);
if (yScale == 0) sc.ScriptError("Texture %s is defined with null y-scale\n", Name.GetChars());
Scale.Y = sc.Float;
if (Scale.Y == 0) sc.ScriptError("Texture %s is defined with null y-scale\n", Name.GetChars());
}
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.
if (w==128 && h==128)
{
tex->xScale = tex->yScale = 2*FRACUNIT;
tex->Scale.X = tex->Scale.Y = 2;
tex->bWorldPanning = true;
}
else if (w==256 && h==256)
{
tex->xScale = tex->yScale = 4*FRACUNIT;
tex->Scale.X = tex->Scale.Y = 4;
tex->bWorldPanning = true;
}
}
@ -147,7 +147,7 @@ FTexture * FTexture::CreateTexture (const char *name, int lumpnum, int usetype)
FTexture::FTexture (const char *name, int lumpnum)
: 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),
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)
@ -562,11 +562,11 @@ FTexture *FTexture::GetRawTexture()
void FTexture::SetScaledSize(int fitwidth, int fitheight)
{
xScale = FLOAT2FIXED(float(Width) / fitwidth);
yScale = FLOAT2FIXED(float(Height) / fitheight);
Scale.X = double(Width) / fitwidth;
Scale.Y =double(Height) / fitheight;
// compensate for roundoff errors
if (MulScale16(xScale, fitwidth) != Width) xScale++;
if (MulScale16(yScale, fitheight) != Height) yScale++;
if (int(Scale.X * fitwidth) != Width) Scale.X += (1 / 65536.);
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.
newtex->bWorldPanning = true;
newtex->SetScaledSize(oldtex->GetScaledWidth(), oldtex->GetScaledHeight());
newtex->LeftOffset = FixedMul(oldtex->GetScaledLeftOffset(), newtex->xScale);
newtex->TopOffset = FixedMul(oldtex->GetScaledTopOffset(), newtex->yScale);
newtex->LeftOffset = int(oldtex->GetScaledLeftOffset() * newtex->Scale.X);
newtex->TopOffset = int(oldtex->GetScaledTopOffset() * newtex->Scale.Y);
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.
newtex->bWorldPanning = true;
newtex->SetScaledSize(oldtex->GetScaledWidth(), oldtex->GetScaledHeight());
newtex->LeftOffset = FixedMul(oldtex->GetScaledLeftOffset(), newtex->xScale);
newtex->TopOffset = FixedMul(oldtex->GetScaledTopOffset(), newtex->yScale);
newtex->LeftOffset = int(oldtex->GetScaledLeftOffset() * newtex->Scale.X);
newtex->TopOffset = int(oldtex->GetScaledTopOffset() * newtex->Scale.Y);
ReplaceTexture(tlist[i], newtex, true);
}
}

View File

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

View File

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

View File

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