- 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) FTexture::FTexture (const char *name, int lumpnum)
: :
Scale(1,1), SourceLump(lumpnum), SourceLump(lumpnum),
bNoDecals(false), bNoRemap0(false), bWorldPanning(false), bNoDecals(false), bNoRemap0(false), bWorldPanning(false),
bMasked(true), bAlphaTexture(false), bHasCanvas(false), bWarped(0), bComplex(false), bMultiPatch(false), bFullNameTexture(false), bMasked(true), bAlphaTexture(false), bHasCanvas(false), bWarped(0), bComplex(false), bMultiPatch(false), bFullNameTexture(false),
Rotations(0xFFFF), SkyOffset(0), Width(0), Height(0) Rotations(0xFFFF), SkyOffset(0), Width(0), Height(0)
@ -148,15 +148,6 @@ FBitmap FTexture::GetBgraBitmap(const PalEntry *remap, int *ptrans)
return bmp; 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 // CheckRealHeight
@ -176,9 +167,6 @@ int FTexture::CheckRealHeight()
{ {
if (pixels[h + w * GetHeight()] != 0) if (pixels[h + w * GetHeight()] != 0)
{ {
// Scale maxy before returning it
h = int((h * 2) / Scale.Y);
h = (h >> 1) + (h & 1);
return h; return h;
} }
} }

View File

@ -602,9 +602,9 @@ 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.
auto gtex = MakeGameTexture(newtex, ETextureType::Override); auto gtex = MakeGameTexture(newtex, ETextureType::Override);
gtex->SetWorldPanning(true); 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->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); 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. // Replace the entire texture and adjust the scaling and offset factors.
auto gtex = MakeGameTexture(newtex, ETextureType::Override); auto gtex = MakeGameTexture(newtex, ETextureType::Override);
gtex->SetWorldPanning(true); 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->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); ReplaceTexture(tlist[i], gtex, true);
} }
} }

View File

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