- floatified texture scale values.

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

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;
}