From f5d5888c22a1d7081120725304376a06380d0982 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 15 Apr 2020 22:03:51 +0200 Subject: [PATCH] - thinned out the Texturemanager interface. --- src/common/textures/hw_material.cpp | 7 +++--- src/common/textures/texture.cpp | 7 +++--- src/common/textures/texturemanager.cpp | 4 ++-- src/common/textures/texturemanager.h | 31 +++++++------------------- src/r_data/gldefs.cpp | 4 ++-- 5 files changed, 20 insertions(+), 33 deletions(-) diff --git a/src/common/textures/hw_material.cpp b/src/common/textures/hw_material.cpp index 57c88099e..7ab3f1321 100644 --- a/src/common/textures/hw_material.cpp +++ b/src/common/textures/hw_material.cpp @@ -79,6 +79,7 @@ FMaterial::FMaterial(FGameTexture * tx, bool expanded) // Note that these layers must present a valid texture even if not used, because empty TMUs in the shader are an undefined condition. imgtex->CreateDefaultBrightmap(); + auto placeholder = TexMan.GameByIndex(1); if (imgtex->Brightmap) { mTextureLayers.Push(imgtex->Brightmap); @@ -86,7 +87,7 @@ FMaterial::FMaterial(FGameTexture * tx, bool expanded) } else { - mTextureLayers.Push(TexMan.ByIndex(1)); + mTextureLayers.Push(placeholder->GetTexture()); } if (imgtex->Detailmap) { @@ -95,7 +96,7 @@ FMaterial::FMaterial(FGameTexture * tx, bool expanded) } else { - mTextureLayers.Push(TexMan.ByIndex(1)); + mTextureLayers.Push(placeholder->GetTexture()); } if (imgtex->Glowmap) { @@ -104,7 +105,7 @@ FMaterial::FMaterial(FGameTexture * tx, bool expanded) } else { - mTextureLayers.Push(TexMan.ByIndex(1)); + mTextureLayers.Push(placeholder->GetTexture()); } if (imgtex->shaderindex >= FIRST_USER_SHADER) diff --git a/src/common/textures/texture.cpp b/src/common/textures/texture.cpp index 4fadb318d..72b57190d 100644 --- a/src/common/textures/texture.cpp +++ b/src/common/textures/texture.cpp @@ -119,6 +119,7 @@ FTexture::FTexture (const char *name, int lumpnum) bMasked(true), bAlphaTexture(false), bHasCanvas(false), bWarped(0), bComplex(false), bMultiPatch(false), bFullNameTexture(false), Rotations(0xFFFF), SkyOffset(0), Width(0), Height(0) { + tempGameTexture = reinterpret_cast(this); bBrightmapChecked = false; bGlowing = false; bAutoGlowing = false; @@ -385,11 +386,11 @@ void FTexture::AddAutoMaterials() auto lump = fileSystem.CheckNumForFullName(lookup, false, ns_global, true); if (lump != -1) { - auto bmtex = TexMan.FindTexture(fileSystem.GetFileFullName(lump), ETextureType::Any, FTextureManager::TEXMAN_TryAny); + auto bmtex = TexMan.FindGameTexture(fileSystem.GetFileFullName(lump), ETextureType::Any, FTextureManager::TEXMAN_TryAny); if (bmtex != nullptr) { - bmtex->bMasked = false; - this->*(layer.pointer) = bmtex; + bmtex->GetTexture()->bMasked = false; + this->*(layer.pointer) = bmtex->GetTexture(); } } } diff --git a/src/common/textures/texturemanager.cpp b/src/common/textures/texturemanager.cpp index e8762431b..6c870006a 100644 --- a/src/common/textures/texturemanager.cpp +++ b/src/common/textures/texturemanager.cpp @@ -332,10 +332,10 @@ FTextureID FTextureManager::GetTextureID (const char *name, ETextureType usetype // //========================================================================== -FTexture *FTextureManager::FindTexture(const char *texname, ETextureType usetype, BITFIELD flags) +FGameTexture *FTextureManager::FindGameTexture(const char *texname, ETextureType usetype, BITFIELD flags) { FTextureID texnum = CheckForTexture (texname, usetype, flags); - return GetTexture(texnum.GetIndex()); + return GetGameTexture(texnum.GetIndex()); } //========================================================================== diff --git a/src/common/textures/texturemanager.h b/src/common/textures/texturemanager.h index 562963990..71edb533d 100644 --- a/src/common/textures/texturemanager.h +++ b/src/common/textures/texturemanager.h @@ -24,52 +24,37 @@ public: private: int ResolveLocalizedTexture(int texnum); - FTexture *InternalGetTexture(int texnum, bool animate, bool localize) + FGameTexture *InternalGetTexture(int texnum, bool animate, bool localize) { if ((unsigned)texnum >= Textures.Size()) return nullptr; if (animate) texnum = Translation[texnum]; if (localize && Textures[texnum].HasLocalization) texnum = ResolveLocalizedTexture(texnum); - return Textures[texnum].Texture->GetTexture(); + return Textures[texnum].Texture; } public: // This only gets used in UI code so we do not need PALVERS handling. - FTexture *GetTextureByName(const char *name, bool animate = false) - { - FTextureID texnum = GetTextureID (name, ETextureType::MiscPatch); - return InternalGetTexture(texnum.GetIndex(), animate, true); - } - FGameTexture* GetGameTextureByName(const char *name, bool animate = false) { - return reinterpret_cast(GetTextureByName(name, animate)); + FTextureID texnum = GetTextureID(name, ETextureType::MiscPatch); + return InternalGetTexture(texnum.GetIndex(), animate, true); } FTexture *GetTexture(FTextureID texnum, bool animate = false) { - return InternalGetTexture(texnum.GetIndex(), animate, true); + return InternalGetTexture(texnum.GetIndex(), animate, true)->GetTexture(); } FGameTexture* GetGameTexture(FTextureID texnum, bool animate = false) { - return reinterpret_cast(GetTexture(texnum, animate)); + return InternalGetTexture(texnum.GetIndex(), animate, true); } - FTexture *ByIndex(int i, bool animate = false) + FGameTexture* GameByIndex(int i, bool animate = false) { return InternalGetTexture(i, animate, true); } - FGameTexture* GameByIndex(int i, bool animate = false) - { - return reinterpret_cast(ByIndex(i, animate)); - } - - FTexture *FindTexture(const char *texname, ETextureType usetype = ETextureType::MiscPatch, BITFIELD flags = TEXMAN_TryAny); - - FGameTexture* FindGameTexture(const char* texname, ETextureType usetype = ETextureType::MiscPatch, BITFIELD flags = TEXMAN_TryAny) - { - return reinterpret_cast(FindTexture(texname, usetype, flags)); - } + FGameTexture* FindGameTexture(const char* texname, ETextureType usetype = ETextureType::MiscPatch, BITFIELD flags = TEXMAN_TryAny); bool OkForLocalization(FTextureID texnum, const char *substitute, int locnum); diff --git a/src/r_data/gldefs.cpp b/src/r_data/gldefs.cpp index d89be2019..d8e04dcd8 100644 --- a/src/r_data/gldefs.cpp +++ b/src/r_data/gldefs.cpp @@ -90,13 +90,13 @@ static void ParseVavoomSkybox() maplump = fileSystem.CheckNumForFullName(sc.String, true); - FTexture *tex = TexMan.FindTexture(sc.String, ETextureType::Wall, FTextureManager::TEXMAN_TryAny); + auto tex = TexMan.FindGameTexture(sc.String, ETextureType::Wall, FTextureManager::TEXMAN_TryAny); if (tex == NULL) { sc.ScriptMessage("Texture '%s' not found in Vavoom skybox '%s'\n", sc.String, sb->GetName().GetChars()); error = true; } - sb->faces[facecount] = tex; + sb->faces[facecount] = tex->GetTexture(); sc.MustGetStringName("}"); } facecount++;