0
0
Fork 0
mirror of https://github.com/ZDoom/Raze.git synced 2025-03-04 16:01:25 +00:00

- eliminate picnums in QAV code.

This commit is contained in:
Christoph Oelckers 2023-01-02 22:01:13 +01:00
parent 9a703639cb
commit 83dfd77bd0
2 changed files with 13 additions and 12 deletions
source/games/blood/src

View file

@ -62,12 +62,12 @@ static void qavInitTileFinderMap()
{ {
// Interpolate between frames if the picnums match. This is safest but could miss interpolations between suitable picnums. // Interpolate between frames if the picnums match. This is safest but could miss interpolations between suitable picnums.
qavPrevTileFinders.Insert("picnum", [](FRAMEINFO* const thisFrame, FRAMEINFO* const prevFrame, const int i) -> TILE_FRAME* { qavPrevTileFinders.Insert("picnum", [](FRAMEINFO* const thisFrame, FRAMEINFO* const prevFrame, const int i) -> TILE_FRAME* {
return prevFrame->tiles[i].picnum == thisFrame->tiles[i].picnum ? &prevFrame->tiles[i] : nullptr; return prevFrame->tiles[i].texid == thisFrame->tiles[i].texid ? &prevFrame->tiles[i] : nullptr;
}); });
// Interpolate between frames if the picnum is valid. This can be problematic if tile indices change between frames. // Interpolate between frames if the picnum is valid. This can be problematic if tile indices change between frames.
qavPrevTileFinders.Insert("index", [](FRAMEINFO* const thisFrame, FRAMEINFO* const prevFrame, const int i) -> TILE_FRAME* { qavPrevTileFinders.Insert("index", [](FRAMEINFO* const thisFrame, FRAMEINFO* const prevFrame, const int i) -> TILE_FRAME* {
return prevFrame->tiles[i].picnum > 0 ? &prevFrame->tiles[i] : nullptr; return prevFrame->tiles[i].texid.isValid() ? &prevFrame->tiles[i] : nullptr;
}); });
// Find previous frame by iterating all previous frame's tiles and return on first matched x coordinate. // Find previous frame by iterating all previous frame's tiles and return on first matched x coordinate.
@ -123,12 +123,12 @@ void GameInterface::RemoveQAVInterpProps(const int res_id)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void DrawFrame(double x, double y, double z, double a, double alpha, int picnum, int stat, int shade, int palnum, bool to3dview) void DrawFrame(double x, double y, double z, double a, double alpha, FTextureID texid, int stat, int shade, int palnum, bool to3dview)
{ {
double scale = z * (1. / 65536.);
if (!to3dview) if (!to3dview)
{ {
auto tex = tileGetTexture(picnum); auto tex = TexMan.GetGameTexture(texid);
double scale = z * (1. / 65536.);
int renderstyle = (stat & RS_NOMASK) ? STYLE_Normal : STYLE_Translucent; int renderstyle = (stat & RS_NOMASK) ? STYLE_Normal : STYLE_Translucent;
int pin = (stat & kQavOrientationLeft) ? -1 : (stat & RS_ALIGN_R) ? 1 : 0; int pin = (stat & kQavOrientationLeft) ? -1 : (stat & RS_ALIGN_R) ? 1 : 0;
auto translation = TRANSLATION(Translation_Remap, palnum); auto translation = TRANSLATION(Translation_Remap, palnum);
@ -153,7 +153,7 @@ void DrawFrame(double x, double y, double z, double a, double alpha, int picnum,
if ((stat & kQavOrientationLeft)) stat |= RS_ALIGN_L; if ((stat & kQavOrientationLeft)) stat |= RS_ALIGN_L;
stat &= ~kQavOrientationLeft; stat &= ~kQavOrientationLeft;
hud_drawsprite(x, y, z, a, picnum, shade, palnum, stat, alpha); hud_drawsprite(x, y, scale, a, texid, shade, palnum, stat, alpha);
} }
} }
@ -180,7 +180,7 @@ void QAV::Draw(int ticks, int stat, int shade, int palnum, bool to3dview, double
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)
{ {
if (thisFrame->tiles[i].picnum > 0) if (thisFrame->tiles[i].texid.isValid())
{ {
TILE_FRAME* const thisTile = &thisFrame->tiles[i]; TILE_FRAME* const thisTile = &thisFrame->tiles[i];
TILE_FRAME* const prevTile = interpolate && interpdata->CanInterpFrameTile(nFrame, i) ? interpdata->PrevTileFinder(thisFrame, prevFrame, i) : nullptr; TILE_FRAME* const prevTile = interpolate && interpdata->CanInterpFrameTile(nFrame, i) ? interpdata->PrevTileFinder(thisFrame, prevFrame, i) : nullptr;
@ -215,7 +215,7 @@ void QAV::Draw(int ticks, int stat, int shade, int palnum, bool to3dview, double
tileAlpha = (tileStat & RS_TRANS1) ? glblend[0].def[!!(tileStat & RS_TRANS2)].alpha : 1.f; tileAlpha = (tileStat & RS_TRANS1) ? glblend[0].def[!!(tileStat & RS_TRANS2)].alpha : 1.f;
} }
DrawFrame(tileX + x, tileY + y, tileZ, (angle - tileA).Degrees(), tileAlpha, thisTile->picnum, tileStat, tileShade + shade, (palnum <= 0 ? thisTile->palnum : palnum), to3dview); DrawFrame(tileX + x, tileY + y, tileZ, (angle - tileA).Degrees(), tileAlpha, thisTile->texid, tileStat, tileShade + shade, (palnum <= 0 ? thisTile->palnum : palnum), to3dview);
} }
} }
} }
@ -294,8 +294,8 @@ void QAV::Precache(int palette)
{ {
for (int j = 0; j < 8; j++) for (int j = 0; j < 8; j++)
{ {
if (frames[i].tiles[j].picnum >= 0) if (frames[i].tiles[j].texid.isValid())
tilePrecacheTile(frames[i].tiles[j].picnum, 0, palette); markTextureForPrecache(frames[i].tiles[j].texid, palette);
} }
} }
} }
@ -410,7 +410,8 @@ QAV* getQAV(int res_id)
// Read TILE_FRAME data. // Read TILE_FRAME data.
for (int j = 0; j < 8; j++) for (int j = 0; j < 8; j++)
{ {
qavdata->frames[i].tiles[j].picnum = fr.ReadInt32(); int tile = fr.ReadInt32();
qavdata->frames[i].tiles[j].texid = tile <= 0 ? FNullTextureID() : tileGetTextureID(tile);
qavdata->frames[i].tiles[j].x = fr.ReadInt32(); qavdata->frames[i].tiles[j].x = fr.ReadInt32();
qavdata->frames[i].tiles[j].y = fr.ReadInt32(); qavdata->frames[i].tiles[j].y = fr.ReadInt32();
qavdata->frames[i].tiles[j].z = fr.ReadInt32(); qavdata->frames[i].tiles[j].z = fr.ReadInt32();

View file

@ -193,7 +193,7 @@ enum
struct TILE_FRAME struct TILE_FRAME
{ {
int picnum; FTextureID texid;
int x; int x;
int y; int y;
int z; int z;