diff --git a/source/core/rendering/scene/hw_flats.cpp b/source/core/rendering/scene/hw_flats.cpp index ad58dfcc8..10de0ef5f 100644 --- a/source/core/rendering/scene/hw_flats.cpp +++ b/source/core/rendering/scene/hw_flats.cpp @@ -37,6 +37,7 @@ #include "hw_renderstate.h" #include "sectorgeometry.h" #include "hw_sections.h" +#include "texturemanager.h" #ifdef _DEBUG CVAR(Int, gl_breaksec, -1, 0) @@ -351,9 +352,8 @@ void HWFlat::ProcessSector(HWDrawInfo *di, sectortype * frontsector, int section if (alpha != 0.f) { - int tilenum = frontsector->floorpicnum; - tileUpdatePicnum(&tilenum); - texture = tileGetTexture(tilenum); + auto texid = frontsector->floortexture(); + texture = TexMan.GetGameTexture(texid, true); if (texture && texture->isValid()) { //iboindex = frontsector->iboindex[sector_t::floor]; @@ -394,9 +394,8 @@ void HWFlat::ProcessSector(HWDrawInfo *di, sectortype * frontsector, int section { //iboindex = frontsector->iboindex[sector_t::ceiling]; - int tilenum = frontsector->ceilingpicnum; - tileUpdatePicnum(&tilenum); - texture = tileGetTexture(tilenum); + auto texid = frontsector->ceilingtexture(); + texture = TexMan.GetGameTexture(texid, true); if (texture && texture->isValid()) { //iboindex = frontsector->iboindex[sector_t::floor]; diff --git a/source/core/rendering/scene/hw_walls.cpp b/source/core/rendering/scene/hw_walls.cpp index 4b58caba2..c9e40f38b 100644 --- a/source/core/rendering/scene/hw_walls.cpp +++ b/source/core/rendering/scene/hw_walls.cpp @@ -1010,9 +1010,8 @@ void HWWall::Process(HWDrawInfo* di, walltype* wal, sectortype* frontsector, sec // normal texture - int tilenum = ((wal->cstat & CSTAT_WALL_1WAY) && wal->nextwall != -1) ? wal->overpicnum : wal->wallpicnum; - tileUpdatePicnum(&tilenum); - texture = tileGetTexture(tilenum); + auto tilenum = ((wal->cstat & CSTAT_WALL_1WAY) && wal->nextwall != -1) ? wal->overtexture() : wal->walltexture(); + texture = TexMan.GetGameTexture(tilenum, true); if (texture && texture->isValid()) { DoOneSidedTexture(di, wal, frontsector, backsector, fch1, fch2, ffh1, ffh2); @@ -1047,9 +1046,8 @@ void HWWall::Process(HWDrawInfo* di, walltype* wal, sectortype* frontsector, sec if (bch1a < fch1 || bch2a < fch2) { - int tilenum = wal->wallpicnum; - tileUpdatePicnum(&tilenum); - texture = tileGetTexture(tilenum); + auto tilenum = wal->walltexture(); + texture = TexMan.GetGameTexture(tilenum, true); if (texture && texture->isValid()) { DoUpperTexture(di, wal, frontsector, backsector, fch1, fch2, bch1a, bch2a); @@ -1059,9 +1057,8 @@ void HWWall::Process(HWDrawInfo* di, walltype* wal, sectortype* frontsector, sec if (wal->cstat & (CSTAT_WALL_MASKED | CSTAT_WALL_1WAY)) { - int tilenum = wal->overpicnum; - tileUpdatePicnum(&tilenum); - texture = tileGetTexture(tilenum); + auto tilenum = wal->overtexture(); + texture = TexMan.GetGameTexture(tilenum, true); if (texture && texture->isValid()) { DoMidTexture(di, wal, frontsector, backsector, fch1, fch2, ffh1, ffh2, bch1, bch2, bfh1, bfh2); @@ -1084,9 +1081,8 @@ void HWWall::Process(HWDrawInfo* di, walltype* wal, sectortype* frontsector, sec if (bfh1 > ffh1 || bfh2 > ffh2) { auto w = (wal->cstat & CSTAT_WALL_BOTTOM_SWAP) ? backwall : wal; - int tilenum = w->wallpicnum; - tileUpdatePicnum(&tilenum); - texture = tileGetTexture(tilenum); + auto tilenum = w->walltexture(); + texture = TexMan.GetGameTexture(tilenum, true); if (texture && texture->isValid()) { DoLowerTexture(di, wal, frontsector, backsector, bfh1, bfh2, ffh1, ffh2); diff --git a/source/core/sectorgeometry.cpp b/source/core/sectorgeometry.cpp index 3ebb15b56..7bfd692d6 100644 --- a/source/core/sectorgeometry.cpp +++ b/source/core/sectorgeometry.cpp @@ -440,7 +440,7 @@ void SectionGeometry::CreatePlaneMesh(Section* section, int plane, const FVector { auto sectorp = §or[section->sector]; // calculate the rest. - auto texture = tileGetTexture(plane ? sectorp->ceilingpicnum : sectorp->floorpicnum); + auto texture = TexMan.GetGameTexture(plane ? sectorp->ceilingtexture() : sectorp->floortexture()); auto& sdata = data[section->index]; auto& entry = sdata.planes[plane]; double fz = sectorp->floorz, cz = sectorp->ceilingz; diff --git a/source/core/textures/buildtiles.cpp b/source/core/textures/buildtiles.cpp index 74fc23ce0..bcc331708 100644 --- a/source/core/textures/buildtiles.cpp +++ b/source/core/textures/buildtiles.cpp @@ -688,3 +688,33 @@ FCanvasTexture* tileGetCanvas(int tilenum) PicAnm picanm; + +// wrappers that allow partial migration to a textureID-based setup. +FTextureID walltype::walltexture() const +{ + auto tex = tileGetTexture(wallpicnum); + return tex ? tex->GetID() : FNullTextureID(); +} +FTextureID walltype::overtexture() const +{ + auto tex = tileGetTexture(overpicnum); + return tex ? tex->GetID() : FNullTextureID(); +} + +FTextureID sectortype::ceilingtexture() const +{ + auto tex = tileGetTexture(ceilingpicnum); + return tex ? tex->GetID() : FNullTextureID(); +} + +FTextureID sectortype::floortexture() const +{ + auto tex = tileGetTexture(floorpicnum); + return tex ? tex->GetID() : FNullTextureID(); +} + +FTextureID spritetypebase::spritetexture() const +{ + auto tex = tileGetTexture(picnum); + return tex ? tex->GetID() : FNullTextureID(); +}