- removed FTexture's Scale variable.

This commit is contained in:
Christoph Oelckers 2020-04-18 00:15:57 +02:00
parent eb369dbf41
commit 7dd108c960
3 changed files with 14 additions and 32 deletions

View file

@ -96,7 +96,7 @@ FTexture * FTexture::CreateTexture(const char *name, int lumpnum, bool allowflat
FTexture::FTexture (const char *name, int lumpnum)
:
Scale(1,1), SourceLump(lumpnum),
SourceLump(lumpnum),
bNoDecals(false), bNoRemap0(false), bWorldPanning(false),
bMasked(true), bAlphaTexture(false), bHasCanvas(false), bWarped(0), bComplex(false), bMultiPatch(false), bFullNameTexture(false),
Rotations(0xFFFF), SkyOffset(0), Width(0), Height(0)
@ -148,15 +148,6 @@ FBitmap FTexture::GetBgraBitmap(const PalEntry *remap, int *ptrans)
return bmp;
}
void FTexture::SetDisplaySize(int fitwidth, int fitheight)
{
Scale.X = double(Width) / fitwidth;
Scale.Y =double(Height) / fitheight;
// compensate for roundoff errors
if (int(Scale.X * fitwidth) != Width) Scale.X += (1 / 65536.);
if (int(Scale.Y * fitheight) != Height) Scale.Y += (1 / 65536.);
}
//====================================================================
//
// CheckRealHeight
@ -176,9 +167,6 @@ int FTexture::CheckRealHeight()
{
if (pixels[h + w * GetHeight()] != 0)
{
// Scale maxy before returning it
h = int((h * 2) / Scale.Y);
h = (h >> 1) + (h & 1);
return h;
}
}

View file

@ -602,9 +602,9 @@ void FTextureManager::AddHiresTextures (int wadnum)
// Replace the entire texture and adjust the scaling and offset factors.
auto gtex = MakeGameTexture(newtex, ETextureType::Override);
gtex->SetWorldPanning(true);
gtex->SetOffsets(0, xs_RoundToInt(oldtex->GetDisplayLeftOffset(0) * newtex->Scale.X), xs_RoundToInt(oldtex->GetDisplayTopOffset(0) * newtex->Scale.Y));
gtex->SetOffsets(1, xs_RoundToInt(oldtex->GetDisplayLeftOffset(1) * newtex->Scale.X), xs_RoundToInt(oldtex->GetDisplayTopOffset(1) * newtex->Scale.Y));
gtex->SetDisplaySize(oldtex->GetDisplayWidth(), oldtex->GetDisplayHeight());
gtex->SetOffsets(0, xs_RoundToInt(oldtex->GetDisplayLeftOffset(0) * gtex->GetScaleX()), xs_RoundToInt(oldtex->GetDisplayTopOffset(0) * gtex->GetScaleY()));
gtex->SetOffsets(1, xs_RoundToInt(oldtex->GetDisplayLeftOffset(1) * gtex->GetScaleX()), xs_RoundToInt(oldtex->GetDisplayTopOffset(1) * gtex->GetScaleY()));
ReplaceTexture(tlist[i], gtex, true);
}
}
@ -698,9 +698,9 @@ void FTextureManager::ParseTextureDef(int lump, FMultipatchTextureBuilder &build
// Replace the entire texture and adjust the scaling and offset factors.
auto gtex = MakeGameTexture(newtex, ETextureType::Override);
gtex->SetWorldPanning(true);
gtex->SetOffsets(0, xs_RoundToInt(oldtex->GetDisplayLeftOffset(0) * newtex->Scale.X), xs_RoundToInt(oldtex->GetDisplayTopOffset(0) * newtex->Scale.Y));
gtex->SetOffsets(1, xs_RoundToInt(oldtex->GetDisplayLeftOffset(1) * newtex->Scale.X), xs_RoundToInt(oldtex->GetDisplayTopOffset(1) * newtex->Scale.Y));
gtex->SetDisplaySize(oldtex->GetDisplayWidth(), oldtex->GetDisplayHeight());
gtex->SetOffsets(0, xs_RoundToInt(oldtex->GetDisplayLeftOffset(0) * gtex->GetScaleX()), xs_RoundToInt(oldtex->GetDisplayTopOffset(0) * gtex->GetScaleY()));
gtex->SetOffsets(1, xs_RoundToInt(oldtex->GetDisplayLeftOffset(1) * gtex->GetScaleX()), xs_RoundToInt(oldtex->GetDisplayTopOffset(1) * gtex->GetScaleY()));
ReplaceTexture(tlist[i], gtex, true);
}
}

View file

@ -43,6 +43,7 @@
#include <vector>
#include "hw_texcontainer.h"
#include "refcounted.h"
#include "xs_Float.h"
// 15 because 0th texture is our texture
#define MAX_CUSTOM_HW_SHADER_TEXTURES 15
@ -271,7 +272,6 @@ public:
void SetNoDecals(bool on) { bNoDecals = on; }
void SetWarpStyle(int style) { bWarped = style; }
bool allowNoDecals() const { return bNoDecals; }
bool isScaled() const { return Scale.X != 1 || Scale.Y != 1; }
bool isMasked() const { return bMasked; }
void SetSkyOffset(int offs) { SkyOffset = offs; }
int GetSkyOffset() const { return SkyOffset; }
@ -286,14 +286,12 @@ public:
void SetSpeed(float fac) { shaderspeed = fac; }
bool UseWorldPanning() const { return bWorldPanning; }
void SetWorldPanning(bool on) { bWorldPanning = on; }
void SetDisplaySize(int fitwidth, int fitheight);
void CopySize(FTexture* BaseTexture)
{
Width = BaseTexture->GetWidth();
Height = BaseTexture->GetHeight();
Scale = BaseTexture->Scale;
}
// This is only used for the null texture and for Heretic's skies.
@ -313,8 +311,6 @@ public:
static bool SmoothEdges(unsigned char * buffer,int w, int h);
protected:
DVector2 Scale;
int SourceLump;
public:
@ -348,7 +344,6 @@ protected:
uint8_t bNoCompress : 1;
int8_t bTranslucent : 2;
int8_t bExpandSprite = -1;
bool bHiresHasColorKey = false; // Support for old color-keyed Doomsday textures
uint16_t Rotations;
int16_t SkyOffset;
@ -365,12 +360,6 @@ protected:
virtual void ResolvePatches() {}
public:
void SetScale(const DVector2 &scale)
{
Scale = scale;
}
protected:
uint16_t Width, Height;
@ -678,7 +667,7 @@ public:
void SetGlowing(PalEntry color) { auto tex = GetTexture(); tex->bAutoGlowing = false; tex->bGlowing = true; tex->GlowColor = color; }
bool isUserContent() const;
int CheckRealHeight() { return Base->CheckRealHeight(); }
int CheckRealHeight() { return xs_RoundToInt(Base->CheckRealHeight() / ScaleY); }
bool isSkybox() const { return Base->isSkybox(); }
void SetSize(int x, int y)
{
@ -690,8 +679,13 @@ public:
{
DisplayWidth = w;
DisplayHeight = h;
ScaleX = w / TexelWidth;
ScaleY = h / TexelHeight;
ScaleX = TexelWidth / w;
ScaleY = TexelHeight / h;
// compensate for roundoff errors
if (int(ScaleX * w) != TexelWidth) ScaleX += (1 / 65536.);
if (int(ScaleY * h) != TexelHeight) ScaleY += (1 / 65536.);
}
void SetOffsets(int which, int x, int y)
{