- added access wrappers for getting texture IDs from the map and used that to rid a large chunk of the renderer of direct tilenum access.

This commit is contained in:
Christoph Oelckers 2022-12-06 09:28:00 +01:00
parent 49f87e6227
commit 028cf2daf5
4 changed files with 44 additions and 19 deletions

View file

@ -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];

View file

@ -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);

View file

@ -440,7 +440,7 @@ void SectionGeometry::CreatePlaneMesh(Section* section, int plane, const FVector
{
auto sectorp = &sector[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;

View file

@ -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();
}