mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 00:41:55 +00:00
- consolidated precaching code and rewrote the core to work on texture IDs.
This commit is contained in:
parent
1a6f808fca
commit
5147826eeb
10 changed files with 76 additions and 141 deletions
|
@ -59,12 +59,12 @@ static void PrecacheTex(FGameTexture* tex, int palid)
|
|||
screen->PrecacheMaterial(mat, palid);
|
||||
}
|
||||
|
||||
static void doprecache(int picnum, int palette)
|
||||
static void doprecache(FTextureID texid, int palette)
|
||||
{
|
||||
if ((palette < (MAXPALOOKUPS - RESERVEDPALS)) && (!lookups.checkTable(palette))) return;
|
||||
|
||||
int palid = TRANSLATION(Translation_Remap + curbasepal, palette);
|
||||
auto tex = tileGetTexture(picnum);
|
||||
auto tex = TexMan.GetGameTexture(texid);
|
||||
PrecacheTex(tex, palid);
|
||||
|
||||
int const mid = -1;// hw_models ? modelManager.CheckModel(picnum, palette) : -1;
|
||||
|
@ -73,7 +73,7 @@ static void doprecache(int picnum, int palette)
|
|||
{
|
||||
if (r_voxels)
|
||||
{
|
||||
int vox = GetExtInfo(tileGetTextureID(picnum)).tiletovox;
|
||||
int vox = GetExtInfo(texid).tiletovox;
|
||||
if (vox >= 0 && vox < MAXVOXELS && voxmodels[vox] && voxmodels[vox]->model)
|
||||
{
|
||||
FHWModelRenderer mr(*screen->RenderState(), 0);
|
||||
|
@ -98,29 +98,35 @@ static void doprecache(int picnum, int palette)
|
|||
|
||||
TMap<int64_t, bool> cachemap;
|
||||
|
||||
void markTileForPrecache(int tilenum, int palnum)
|
||||
void markTextureForPrecache(FTextureID nTex, int palnum)
|
||||
{
|
||||
int i, j;
|
||||
auto nTex = tileGetTextureID(tilenum);
|
||||
auto& picanm = GetExtInfo(nTex).picanm;
|
||||
if (picanm.type() == PICANM_ANIMTYPE_BACK)
|
||||
{
|
||||
i = tilenum - picanm.num;
|
||||
j = tilenum;
|
||||
i = nTex.GetIndex() - picanm.num;
|
||||
j = nTex.GetIndex();
|
||||
}
|
||||
else
|
||||
{
|
||||
i = tilenum;
|
||||
j = tilenum + picanm.num * ((picanm.type() == PICANM_ANIMTYPE_OSC) ? 2 : 1);
|
||||
i = nTex.GetIndex();
|
||||
j = nTex.GetIndex() + picanm.num * ((picanm.type() == PICANM_ANIMTYPE_OSC) ? 2 : 1);
|
||||
}
|
||||
|
||||
for (; i <= j; i++)
|
||||
for (; i <= j; i = i + 1)
|
||||
{
|
||||
int64_t val = i + (int64_t(palnum) << 32);
|
||||
cachemap.Insert(val, true);
|
||||
}
|
||||
}
|
||||
|
||||
void markTextureForPrecache(const char* texname, int palnum)
|
||||
{
|
||||
auto texid = TexMan.CheckForTexture(texname, ETextureType::Any);
|
||||
if (texid.isValid()) markTextureForPrecache(texid, palnum);
|
||||
}
|
||||
|
||||
|
||||
void precacheMarkedTiles()
|
||||
{
|
||||
screen->StartPrecaching();
|
||||
|
@ -128,9 +134,9 @@ void precacheMarkedTiles()
|
|||
decltype(cachemap)::Pair* pair;
|
||||
while (it.NextPair(pair))
|
||||
{
|
||||
int dapicnum = pair->Key & 0x7fffffff;
|
||||
int dapalnum = pair->Key >> 32;
|
||||
doprecache(dapicnum, dapalnum);
|
||||
int texid = pair->Key & 0x7fffffff;
|
||||
int palnum = pair->Key >> 32;
|
||||
doprecache(FSetTextureID(texid), palnum);
|
||||
}
|
||||
|
||||
// Cache everything the map explicitly declares.
|
||||
|
@ -148,3 +154,21 @@ void precacheMarkedTiles()
|
|||
cachemap.Clear();
|
||||
}
|
||||
|
||||
void precacheMap()
|
||||
{
|
||||
for (auto& sect : sector)
|
||||
{
|
||||
markTextureForPrecache(sect.ceilingtexture(), sect.ceilingpal);
|
||||
markTextureForPrecache(sect.floortexture(), sect.floorpal);
|
||||
}
|
||||
|
||||
for (auto& wal : wall)
|
||||
{
|
||||
markTextureForPrecache(wal.walltexture(), wal.pal);
|
||||
|
||||
if (wal.twoSided())
|
||||
{
|
||||
markTextureForPrecache(wal.overtexture(), wal.pal);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include "textureid.h"
|
||||
|
||||
void PrecacheHardwareTextures(int nTile);
|
||||
void markTileForPrecache(int tilenum, int palnum);
|
||||
void markTextureForPrecache(FTextureID texid, int palnum);
|
||||
void markTextureForPrecache(const char* texname);
|
||||
void markVoxelForPrecache(int voxnum);
|
||||
void precacheMarkedTiles();
|
||||
void precacheMap();
|
||||
|
|
|
@ -63,8 +63,8 @@ void tilePrecacheTile(int nTile, int nType, int palette)
|
|||
}
|
||||
while (n--)
|
||||
{
|
||||
markTileForPrecache(nTile, palette);
|
||||
nTile += 1 + GetExtInfo(nTex).picanm.num;
|
||||
markTextureForPrecache(nTex, palette);
|
||||
nTex = nTex + 1 + GetExtInfo(nTex).picanm.num;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -259,19 +259,8 @@ void PreloadCache()
|
|||
if (!r_precache) return;
|
||||
int skyTile = -1;
|
||||
// Fonts
|
||||
for (auto& sect : sector)
|
||||
{
|
||||
tilePrecacheTile(sect.floorpicnum, 0, sect.floorpal);
|
||||
tilePrecacheTile(sect.ceilingpicnum, 0, sect.ceilingpal);
|
||||
if ((sect.ceilingstat & CSTAT_SECTOR_SKY) != 0 && skyTile == -1)
|
||||
skyTile = sect.ceilingpicnum;
|
||||
}
|
||||
for (auto& wal : wall)
|
||||
{
|
||||
tilePrecacheTile(wal.wallpicnum, 0, wal.pal);
|
||||
if (wal.overpicnum >= 0)
|
||||
tilePrecacheTile(wal.overpicnum, 0, wal.pal);
|
||||
}
|
||||
precacheMap();
|
||||
|
||||
BloodSpriteIterator it;
|
||||
while (auto actor = it.Next())
|
||||
{
|
||||
|
@ -312,6 +301,11 @@ void PreloadCache()
|
|||
seqPrecacheId(dudeInfo[31].seqStartID + 18, 0);
|
||||
|
||||
/* fixme: cache the composite sky. These are useless.
|
||||
for (auto& sect : sector)
|
||||
{
|
||||
if ((sect.ceilingstat & CSTAT_SECTOR_SKY) != 0 && skyTile == -1)
|
||||
skyTile = sect.ceilingtexture();
|
||||
}
|
||||
if (skyTile > -1 && skyTile < kMaxTiles)
|
||||
{
|
||||
for (int i = 1; i < gSkyCount; i++)
|
||||
|
|
|
@ -989,7 +989,13 @@ static int LoadTheMap(MapRecord *mi, player_struct*p, int gamemode)
|
|||
allignwarpelevators();
|
||||
resetpspritevars(gamemode, pos, mapangle(lbang));
|
||||
|
||||
if (r_precache)
|
||||
{
|
||||
if (isRR()) cacheit_r(); else cacheit_d();
|
||||
|
||||
precacheMap();
|
||||
precacheMarkedTiles();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ BEGIN_DUKE_NS
|
|||
inline void tloadtile(int tilenum, int palnum = 0)
|
||||
{
|
||||
assert(tilenum < MAXTILES);
|
||||
markTileForPrecache(tilenum, palnum);
|
||||
markTextureForPrecache(tileGetTextureID(tilenum), palnum);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -225,31 +225,14 @@ static void cachegoodsprites(void)
|
|||
|
||||
void cacheit_d(void)
|
||||
{
|
||||
if (!r_precache) return;
|
||||
|
||||
cachegoodsprites();
|
||||
|
||||
for (auto& wal : wall)
|
||||
{
|
||||
tloadtile(wal.wallpicnum, wal.pal);
|
||||
if (wal.overpicnum >= 0)
|
||||
tloadtile(wal.overpicnum, wal.pal);
|
||||
}
|
||||
|
||||
for (auto& sect: sector)
|
||||
{
|
||||
tloadtile(sect.floorpicnum, sect.floorpal);
|
||||
tloadtile(sect.ceilingpicnum, sect.ceilingpal);
|
||||
|
||||
DukeSectIterator it(§);
|
||||
DukeSpriteIterator it;
|
||||
while (auto act = it.Next())
|
||||
{
|
||||
if (act->spr.scale.X != 0 && act->spr.scale.Y != 0 && (act->spr.cstat & CSTAT_SPRITE_INVISIBLE) == 0)
|
||||
cachespritenum(act);
|
||||
}
|
||||
}
|
||||
|
||||
precacheMarkedTiles();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
|
@ -37,7 +37,8 @@ BEGIN_DUKE_NS
|
|||
|
||||
static inline void tloadtile(int tilenum, int palnum = 0)
|
||||
{
|
||||
markTileForPrecache(tilenum, palnum);
|
||||
assert(tilenum < MAXTILES);
|
||||
markTextureForPrecache(tileGetTextureID(tilenum), palnum);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -365,30 +366,14 @@ static void cachegoodsprites(void)
|
|||
|
||||
void cacheit_r(void)
|
||||
{
|
||||
if (!r_precache) return;
|
||||
|
||||
cachegoodsprites();
|
||||
|
||||
for (auto& wal : wall)
|
||||
{
|
||||
tloadtile(wal.wallpicnum, wal.pal);
|
||||
if(wal.overpicnum >= 0)
|
||||
tloadtile(wal.overpicnum, wal.pal);
|
||||
}
|
||||
|
||||
for (auto& sect: sector)
|
||||
{
|
||||
tloadtile(sect.floorpicnum, sect.floorpal);
|
||||
tloadtile(sect.ceilingpicnum, sect.ceilingpal);
|
||||
|
||||
DukeSectIterator it(§);
|
||||
DukeSpriteIterator it;
|
||||
while (auto act = it.Next())
|
||||
{
|
||||
if(act->spr.scale.X != 0 && act->spr.scale.Y != 0 && (act->spr.cstat & CSTAT_SPRITE_INVISIBLE) == 0)
|
||||
if (act->spr.scale.X != 0 && act->spr.scale.Y != 0 && (act->spr.cstat & CSTAT_SPRITE_INVISIBLE) == 0)
|
||||
cachespritenum(act);
|
||||
}
|
||||
}
|
||||
precacheMarkedTiles();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
|
@ -44,32 +44,12 @@ void precache()
|
|||
{
|
||||
if (!r_precache) return;
|
||||
|
||||
for (auto& sect: sector)
|
||||
{
|
||||
int j = sect.ceilingpicnum;
|
||||
markTileForPrecache(j, sect.ceilingpal);
|
||||
|
||||
j = sect.floorpicnum;
|
||||
markTileForPrecache(j, sect.floorpal);
|
||||
}
|
||||
|
||||
for(auto& wal : wall)
|
||||
{
|
||||
int j = wal.wallpicnum;
|
||||
markTileForPrecache(j, wal.pal);
|
||||
|
||||
if (wal.twoSided())
|
||||
{
|
||||
j = wal.overpicnum;
|
||||
markTileForPrecache(j, wal.pal);
|
||||
}
|
||||
}
|
||||
precacheMap();
|
||||
|
||||
ExhumedSpriteIterator it;
|
||||
while (auto ac = it.Next())
|
||||
{
|
||||
int j = ac->spr.picnum;
|
||||
markTileForPrecache(j, ac->spr.pal);
|
||||
markTextureForPrecache(ac->spr.spritetexture(), ac->spr.pal);
|
||||
}
|
||||
precacheMarkedTiles();
|
||||
}
|
||||
|
|
|
@ -45,16 +45,11 @@ not load" error messages.
|
|||
|
||||
BEGIN_SW_NS
|
||||
|
||||
// Run the game with the -CACHEPRINT option and redirect to a file.
|
||||
// It will save out the tile and sound number every time one caches.
|
||||
//
|
||||
// sw -map $bullet -cacheprint > foofile
|
||||
|
||||
void PreCacheRange(int start_pic, int end_pic, int pal = 0)
|
||||
{
|
||||
for (int j = start_pic; j <= end_pic; j++)
|
||||
{
|
||||
markTileForPrecache(j, pal);
|
||||
markTextureForPrecache(tileGetTextureID(j), pal);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,44 +64,9 @@ void PreCacheOverride(void)
|
|||
SWStatIterator it(STAT_CEILING_FLOOR_PIC_OVERRIDE);
|
||||
while (auto actor = it.Next())
|
||||
{
|
||||
int j = SP_TAG2(actor);
|
||||
int j = SP_TAG2(actor); // picnum
|
||||
if(j >= 0 && j <= MAXTILES)
|
||||
markTileForPrecache(j, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void precacheMap(void)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
sectortype* sectp;
|
||||
walltype* wp;
|
||||
|
||||
for(auto& sec: sector)
|
||||
{
|
||||
j = sec.ceilingpicnum;
|
||||
markTileForPrecache(j, sec.ceilingpal);
|
||||
|
||||
j = sec.floorpicnum;
|
||||
markTileForPrecache(j, sec.floorpal);
|
||||
}
|
||||
|
||||
for (auto& wal : wall)
|
||||
{
|
||||
j = wal.wallpicnum;
|
||||
markTileForPrecache(j, wal.pal);
|
||||
|
||||
if (wal.overpicnum > 0 && wal.overpicnum < MAXTILES)
|
||||
{
|
||||
j = wal.overpicnum;
|
||||
markTileForPrecache(j, wal.pal);
|
||||
}
|
||||
markTextureForPrecache(tileGetTextureID(j), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -457,7 +417,7 @@ void PreCacheActor(void)
|
|||
break;
|
||||
|
||||
default:
|
||||
markTileForPrecache(pic, pal);
|
||||
markTextureForPrecache(tileGetTextureID(pic), pal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ class DukeCommonStatusBar : RazeStatusBar
|
|||
for (i = connecthead; i >= 0; i = connectpoint2[i])
|
||||
if (i > j) j = i;
|
||||
|
||||
auto tex = tileGetTexture(TILE_FRAGBAR);
|
||||
auto tex = ("FRAGBAR");
|
||||
for (int y = 0; y < 32; y += 8)
|
||||
DrawTexture(twod, tex, 0, 0, DTA_FullscreenScale, FSMode_Fit320x200, DTA_ScaleX, 1.001, DTA_ScaleY, 1.001, TAG_Done);
|
||||
|
||||
|
|
|
@ -329,7 +329,7 @@ class ExhumedStatusBar : RazeStatusBar
|
|||
}
|
||||
/* non-implemented weapon icon.
|
||||
int wicon = 0;// ammo_sprites[weapon];
|
||||
img = tileGetTexture(wicon);
|
||||
img = ammo_sprites[weapon];
|
||||
imgScale = baseScale / img.GetDisplayHeight();
|
||||
let imgX = 21.125;
|
||||
let strlen = format.Len();
|
||||
|
|
Loading…
Reference in a new issue