From db93f2969e49dc71348fe28c81a8055217d315f5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 6 Jun 2020 19:00:38 +0200 Subject: [PATCH] - fixed offsets for hires replacements of already scaled textures. --- src/common/textures/texturemanager.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/common/textures/texturemanager.cpp b/src/common/textures/texturemanager.cpp index fc6f7f35e2..f0163ab337 100644 --- a/src/common/textures/texturemanager.cpp +++ b/src/common/textures/texturemanager.cpp @@ -625,8 +625,12 @@ void FTextureManager::AddHiresTextures (int wadnum) auto gtex = MakeGameTexture(newtex, nullptr, ETextureType::Override); gtex->SetWorldPanning(true); gtex->SetDisplaySize(oldtex->GetDisplayWidth(), oldtex->GetDisplayHeight()); - gtex->SetOffsets(0, xs_RoundToInt(oldtex->GetTexelLeftOffset(0) * gtex->GetScaleX()), xs_RoundToInt(oldtex->GetTexelTopOffset(0) * gtex->GetScaleY())); - gtex->SetOffsets(1, xs_RoundToInt(oldtex->GetTexelLeftOffset(1) * gtex->GetScaleX()), xs_RoundToInt(oldtex->GetTexelTopOffset(1) * gtex->GetScaleY())); + double xscale1 = oldtex->GetTexelLeftOffset(0) * gtex->GetScaleX() / oldtex->GetScaleX(); + double xscale2 = oldtex->GetTexelLeftOffset(1) * gtex->GetScaleX() / oldtex->GetScaleX(); + double yscale1 = oldtex->GetTexelTopOffset(0) * gtex->GetScaleY() / oldtex->GetScaleY(); + double yscale2 = oldtex->GetTexelTopOffset(1) * gtex->GetScaleY() / oldtex->GetScaleY(); + gtex->SetOffsets(0, xs_RoundToInt(xscale1), xs_RoundToInt(yscale1)); + gtex->SetOffsets(1, xs_RoundToInt(xscale2), xs_RoundToInt(yscale2)); ReplaceTexture(tlist[i], gtex, true); } } @@ -721,8 +725,12 @@ void FTextureManager::ParseTextureDef(int lump, FMultipatchTextureBuilder &build auto gtex = MakeGameTexture(newtex, nullptr, ETextureType::Override); gtex->SetWorldPanning(true); gtex->SetDisplaySize(oldtex->GetDisplayWidth(), oldtex->GetDisplayHeight()); - gtex->SetOffsets(0, xs_RoundToInt(oldtex->GetTexelLeftOffset(0) * gtex->GetScaleX()), xs_RoundToInt(oldtex->GetTexelTopOffset(0) * gtex->GetScaleY())); - gtex->SetOffsets(1, xs_RoundToInt(oldtex->GetTexelLeftOffset(1) * gtex->GetScaleX()), xs_RoundToInt(oldtex->GetTexelTopOffset(1) * gtex->GetScaleY())); + double xscale1 = oldtex->GetTexelLeftOffset(0) * gtex->GetScaleX() / oldtex->GetScaleX(); + double xscale2 = oldtex->GetTexelLeftOffset(1) * gtex->GetScaleX() / oldtex->GetScaleX(); + double yscale1 = oldtex->GetTexelTopOffset(0) * gtex->GetScaleY() / oldtex->GetScaleY(); + double yscale2 = oldtex->GetTexelTopOffset(1) * gtex->GetScaleY() / oldtex->GetScaleY(); + gtex->SetOffsets(0, xs_RoundToInt(xscale1), xs_RoundToInt(yscale1)); + gtex->SetOffsets(1, xs_RoundToInt(xscale2), xs_RoundToInt(yscale2)); ReplaceTexture(tlist[i], gtex, true); } }