- minor cleanup on the texture layer data in FTexture.

This commit is contained in:
Christoph Oelckers 2018-03-31 12:27:41 +02:00
commit 410d6817b2
4 changed files with 48 additions and 56 deletions

View file

@ -196,12 +196,6 @@ FTexture::MiscGLInfo::MiscGLInfo() throw()
Material[1] = Material[0] = NULL;
SystemTexture[1] = SystemTexture[0] = NULL;
Brightmap = NULL;
Normal = NULL;
Specular = NULL;
Metallic = NULL;
Roughness = NULL;
AmbientOcclusion = NULL;
}
FTexture::MiscGLInfo::~MiscGLInfo()
@ -215,9 +209,6 @@ FTexture::MiscGLInfo::~MiscGLInfo()
SystemTexture[i] = NULL;
}
// this is just a reference to another texture in the texture manager.
Brightmap = NULL;
if (areas != NULL) delete [] areas;
areas = NULL;
}
@ -234,7 +225,7 @@ void FTexture::CreateDefaultBrightmap()
// Check for brightmaps
if (UseBasePalette() && HasGlobalBrightmap &&
UseType != ETextureType::Decal && UseType != ETextureType::MiscPatch && UseType != ETextureType::FontChar &&
gl_info.Brightmap == NULL && bWarped == 0
Brightmap == NULL && bWarped == 0
)
{
// May have one - let's check when we use this texture
@ -248,9 +239,9 @@ void FTexture::CreateDefaultBrightmap()
{
// Create a brightmap
DPrintf(DMSG_NOTIFY, "brightmap created for texture '%s'\n", Name.GetChars());
gl_info.Brightmap = new FBrightmapTexture(this);
Brightmap = new FBrightmapTexture(this);
gl_info.bBrightmapChecked = 1;
TexMan.AddTexture(gl_info.Brightmap);
TexMan.AddTexture(Brightmap);
return;
}
}
@ -650,12 +641,12 @@ void gl_ParseMaterial(FScanner &sc, int deflump)
FTexture **bindings[6] =
{
&tex->gl_info.Brightmap,
&tex->gl_info.Normal,
&tex->gl_info.Specular,
&tex->gl_info.Metallic,
&tex->gl_info.Roughness,
&tex->gl_info.AmbientOcclusion
&tex->Brightmap,
&tex->Normal,
&tex->Specular,
&tex->Metallic,
&tex->Roughness,
&tex->AmbientOcclusion
};
for (int i = 0; keywords[i] != nullptr; i++)
{
@ -758,7 +749,7 @@ void gl_ParseBrightmap(FScanner &sc, int deflump)
*/
bmtex->bMasked = false;
tex->gl_info.Brightmap = bmtex;
tex->Brightmap = bmtex;
}
tex->gl_info.bDisableFullbright = disable_fullbright;
}
@ -772,27 +763,23 @@ void gl_ParseBrightmap(FScanner &sc, int deflump)
struct AutoTextureSearchPath
{
const char *path;
ptrdiff_t offset;
void SetTexture(FTexture *material, FTexture *texture) const
{
*reinterpret_cast<FTexture**>(reinterpret_cast<uint8_t*>(&material->gl_info) + offset) = texture;
}
FTexture *FTexture::*pointer;
};
static AutoTextureSearchPath autosearchpaths[] =
{
{ "brightmaps/auto/", offsetof(FTexture::MiscGLInfo, Brightmap) }, // For backwards compatibility
{ "materials/brightmaps/auto/", offsetof(FTexture::MiscGLInfo, Brightmap) },
{ "materials/normalmaps/auto/", offsetof(FTexture::MiscGLInfo, Normal) },
{ "materials/specular/auto/", offsetof(FTexture::MiscGLInfo, Specular) },
{ "materials/metallic/auto/", offsetof(FTexture::MiscGLInfo, Metallic) },
{ "materials/roughness/auto/", offsetof(FTexture::MiscGLInfo, Roughness) },
{ "materials/ao/auto/", offsetof(FTexture::MiscGLInfo, AmbientOcclusion) }
{ "brightmaps/auto/", &FTexture::Brightmap }, // For backwards compatibility
{ "materials/brightmaps/auto/", &FTexture::Brightmap },
{ "materials/normalmaps/auto/", &FTexture::Normal },
{ "materials/specular/auto/", &FTexture::Specular },
{ "materials/metallic/auto/", &FTexture::Metallic },
{ "materials/roughness/auto/", &FTexture::Roughness },
{ "materials/ao/auto/", &FTexture::AmbientOcclusion }
};
void AddAutoMaterials()
{
// Fixme: let this be driven by the texture manager, not the renderer.
int num = Wads.GetNumLumps();
for (int i = 0; i < num; i++)
{
@ -804,11 +791,12 @@ void AddAutoMaterials()
TArray<FTextureID> list;
FString texname = ExtractFileBase(name, false);
TexMan.ListTextures(texname, list);
auto bmtex = TexMan.FindTexture(name, ETextureType::Any, FTextureManager::TEXMAN_TryAny);
auto bmtex = TexMan.FindTexture(name, ETextureType::Any, FTextureManager::TEXMAN_TryAny || FTextureManager::TEXMAN_DontCreate || FTextureManager::TEXMAN_ShortNameOnly );
for (auto texid : list)
{
bmtex->bMasked = false;
searchpath.SetTexture(TexMan[texid], bmtex);
auto tex = TexMan[texid];
if (tex != nullptr) tex->*(searchpath.pointer) = bmtex;
}
}
}