From 192ea40634735e21203dd930ffd5b69e8e20a6ef Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 4 May 2020 21:24:36 +0200 Subject: [PATCH] - fixed order of multipatch texture initialization. This didn't play well with hires replacements - the texture size needs to be set as early as possible. --- src/common/textures/gametexture.h | 4 ++++ src/common/textures/multipatchtexturebuilder.cpp | 12 ++++++------ src/common/textures/texturemanager.cpp | 5 +++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/common/textures/gametexture.h b/src/common/textures/gametexture.h index 3b2b69029..31864f9eb 100644 --- a/src/common/textures/gametexture.h +++ b/src/common/textures/gametexture.h @@ -240,6 +240,10 @@ public: if (int(ScaleY * h) != TexelHeight) ScaleY += (1 / 65536.); } + void SetBase(FTexture* Tex) + { + Base = Tex; + } void SetOffsets(int which, int x, int y) { LeftOffset[which] = x; diff --git a/src/common/textures/multipatchtexturebuilder.cpp b/src/common/textures/multipatchtexturebuilder.cpp index fcd12bac5..46447f86d 100644 --- a/src/common/textures/multipatchtexturebuilder.cpp +++ b/src/common/textures/multipatchtexturebuilder.cpp @@ -138,19 +138,18 @@ void FMultipatchTextureBuilder::MakeTexture(BuildInfo &buildinfo, ETextureType u { buildinfo.texture = new FGameTexture(nullptr, buildinfo.Name); buildinfo.texture->SetUseType(usetype); + buildinfo.texture->SetSize(buildinfo.Width, buildinfo.Height); buildinfo.texture->SetOffsets(0, buildinfo.LeftOffset[0], buildinfo.TopOffset[0]); // These are needed for construction of other multipatch textures. buildinfo.texture->SetOffsets(1, buildinfo.LeftOffset[1], buildinfo.TopOffset[1]); + buildinfo.texture->SetScale((float)buildinfo.Scale.X, (float)buildinfo.Scale.X); + buildinfo.texture->SetWorldPanning(buildinfo.bWorldPanning); + buildinfo.texture->SetNoDecals(buildinfo.bNoDecals); TexMan.AddGameTexture(buildinfo.texture); } void FMultipatchTextureBuilder::AddImageToTexture(FImageTexture *tex, BuildInfo& buildinfo) { - buildinfo.texture->Setup(tex); - buildinfo.texture->SetOffsets(0, buildinfo.LeftOffset[0], buildinfo.TopOffset[0]); - buildinfo.texture->SetOffsets(1, buildinfo.LeftOffset[1], buildinfo.TopOffset[1]); - buildinfo.texture->SetScale((float)buildinfo.Scale.X, (float)buildinfo.Scale.X); - buildinfo.texture->SetWorldPanning(buildinfo.bWorldPanning); - buildinfo.texture->SetNoDecals(buildinfo.bNoDecals); + buildinfo.texture->SetBase(tex); calcShouldUpscale(buildinfo.texture); // calculate this once at insertion } @@ -874,6 +873,7 @@ void FMultipatchTextureBuilder::ResolveAllPatches() for (int i = BuiltTextures.Size()-1; i>= 0; i--) { auto &buildinfo = BuiltTextures[i]; + bool hasEmpty = false; for (unsigned j = 0; j < buildinfo.Inits.Size(); j++) diff --git a/src/common/textures/texturemanager.cpp b/src/common/textures/texturemanager.cpp index 80458a6ab..eac5f3008 100644 --- a/src/common/textures/texturemanager.cpp +++ b/src/common/textures/texturemanager.cpp @@ -625,8 +625,9 @@ void FTextureManager::AddHiresTextures (int wadnum) auto gtex = MakeGameTexture(newtex, nullptr, ETextureType::Override); gtex->SetWorldPanning(true); gtex->SetDisplaySize(oldtex->GetDisplayWidth(), oldtex->GetDisplayHeight()); - gtex->SetOffsets(0, oldtex->GetTexelLeftOffset(0), oldtex->GetTexelTopOffset(0)); - gtex->SetOffsets(1, oldtex->GetTexelLeftOffset(1), oldtex->GetTexelTopOffset(1)); + + 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); } }