From dc9c7afa246f1e318e2b03cd17e6d9e39b3b2694 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 15 Dec 2018 16:05:48 +0100 Subject: [PATCH] - reimplemented the GetRawTexture redirect. --- src/textures/formats/multipatchtexture.h | 2 ++ src/textures/texture.cpp | 16 +++++++++++++++- src/textures/textures.h | 5 +++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/textures/formats/multipatchtexture.h b/src/textures/formats/multipatchtexture.h index f1284e0a9..3d7800832 100644 --- a/src/textures/formats/multipatchtexture.h +++ b/src/textures/formats/multipatchtexture.h @@ -1,4 +1,5 @@ #pragma once +#include "sc_man.h" //========================================================================== // @@ -28,6 +29,7 @@ struct TexPart class FMultiPatchTexture : public FImageSource { + friend class FTexture; public: FMultiPatchTexture(int w, int h, const TArray &parts, bool complex, bool textual); diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index ec09c3898..6f01f0e4f 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -50,6 +50,7 @@ #include "swrenderer/textures/r_swtexture.h" #include "imagehelpers.h" #include "image.h" +#include "formats/multipatchtexture.h" FTexture *CreateBrightmapTexture(FImageSource*); @@ -221,7 +222,20 @@ FBitmap FTexture::GetBgraBitmap(PalEntry *remap, int *ptrans) FTexture *FTexture::GetRawTexture() { - return this; + if (OffsetLess) return OffsetLess; + // Reject anything that cannot have been a single-patch multipatch texture in vanilla. + auto image = static_cast(GetImage()); + if (bMultiPatch != 1 || UseType != ETextureType::Wall || Scale.X != 1 || Scale.Y != 1 || bWorldPanning || image == nullptr || image->NumParts != 1) + { + OffsetLess = this; + return this; + } + // Set up a new texture that directly references the underlying patch. + // From here we cannot retrieve the original texture made for it, so just create a new one. + FImageSource *source = image->Parts[0].Image; + OffsetLess = new FImageTexture(source, ""); + TexMan.AddTexture(OffsetLess); + return OffsetLess; } void FTexture::SetScaledSize(int fitwidth, int fitheight) diff --git a/src/textures/textures.h b/src/textures/textures.h index d25026634..e40b9fc0a 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -338,7 +338,7 @@ public: int GetSkyOffset() const { return SkyOffset; } FTextureID GetID() const { return id; } PalEntry GetSkyCapColor(bool bottom); - virtual FTexture *GetRawTexture(); // for FMultiPatchTexture to override + FTexture *GetRawTexture(); virtual int GetSourceLump() { return SourceLump; } // needed by the scripted GetName method. void GetGlowColor(float *data); bool isGlowing() const { return bGlowing; } @@ -371,11 +371,12 @@ protected: public: FHardwareTextureContainer SystemTextures; protected: - //IHardwareTexture *SystemTexture[2] = { nullptr, nullptr }; FSoftwareTexture *SoftwareTexture = nullptr; // None of the following pointers are owned by this texture, they are all controlled by the texture manager. + // Offset-less version for COMPATF_MASKEDMIDTEX + FTexture *OffsetLess = nullptr; // Paletted variant FTexture *PalVersion = nullptr; // External hires texture