- use texture IDs in the model interface.

This commit is contained in:
Christoph Oelckers 2022-12-30 18:18:58 +01:00
parent 1bc9de1cf0
commit b2493116f8
5 changed files with 11 additions and 10 deletions

View file

@ -5,6 +5,7 @@
#include "hw_voxels.h"
#include "gamefuncs.h"
#include "tiletexture.h"
#include "buildtiles.h"
#include "build.h"
@ -57,7 +58,7 @@ int ModelManager::DefineFrame(int modelid, const char* framename, int tilenum, i
mframe.framenum = frm;
mframe.skinnum = skinnum;
mframe.smoothduration = smoothduration;
auto key = FrameMapKey(tilenum, pal);
auto key = FrameMapKey(tileGetTextureID(tilenum), pal);
frameMap.Insert(key, mframe);
return key;
}
@ -151,7 +152,7 @@ int ModelManager::UndefineTile(int tile)
// delete all entries from the map that reference this tile
for (int i = 0; i < MAXPALOOKUPS; i++)
{
frameMap.Remove(FrameMapKey(tile, i));
frameMap.Remove(FrameMapKey(tileGetTextureID(tile), i));
}
return 0;
}

View file

@ -56,9 +56,9 @@ struct ModelManager
TArray<ModelDescriptor> modelDescs;
TMap<unsigned, ModelTileFrame> frameMap;
unsigned FrameMapKey(unsigned tilenum, unsigned palette)
unsigned FrameMapKey(FTextureID tilenum, unsigned palette)
{
return tilenum + (palette < 16); // good enough for now - should later be redirected to the underlying texture ID.
return tilenum.GetIndex() + (palette < 20);
}
// Interface for the .def parser
@ -70,11 +70,11 @@ struct ModelManager
int DefineHud(int modelid, int tilex, FVector3 add, int angadd, int flags, int fov);
int UndefineTile(int tile);
int UndefineModel(int modelid);
bool CheckModel(int tilenum, int pal)
bool CheckModel(FTextureID tilenum, int pal)
{
return frameMap.CheckKey(FrameMapKey(tilenum, pal)) != nullptr;
}
ModelTileFrame* GetModel(int tilenum, int pal)
ModelTileFrame* GetModel(FTextureID tilenum, int pal)
{
return frameMap.CheckKey(FrameMapKey(tilenum, pal));
}

View file

@ -297,7 +297,7 @@ void HWDrawInfo::DispatchSprites()
if (!(actor->sprext.renderflags & SPREXT_NOTMD) && !(tspr->cstat2 & CSTAT2_SPRITE_NOMODEL))
{
auto pt = modelManager.GetModel(tspr->picnum, tspr->pal);
auto pt = modelManager.GetModel(tspr->spritetexture(), tspr->pal);
if (hw_models && pt && pt->modelid >= 0 && pt->framenum >= 0)
{
//HWSprite hwsprite;

View file

@ -635,7 +635,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
case 6:
case 7:
{
if (hw_models && modelManager.CheckModel(pTSprite->picnum, pTSprite->pal) && !(owneractor->sprext.renderflags & SPREXT_NOTMD))
if (hw_models && modelManager.CheckModel(pTSprite->spritetexture(), pTSprite->pal) && !(owneractor->sprext.renderflags & SPREXT_NOTMD))
break;
// Can be overridden by def script

View file

@ -63,11 +63,11 @@ void drawshadows(tspriteArray& tsprites, tspritetype* t, DDukeActor* h)
shadowspr->pos.Z = floorz;
shadowspr->pal = 4;
if (hw_models && modelManager.CheckModel(t->picnum, t->pal))
if (hw_models && modelManager.CheckModel(t->spritetexture(), t->pal))
{
shadowspr->scale.Y = (0);
// 512:trans reverse
//1024:tell MD2SPRITE.C to use Z-buffer hacks to hide overdraw issues
//1024:tell MD2SPRITE.C to use Z-buffer hacks to hide overdraw issues (todo: use a stencil to do this right.)
shadowspr->clipdist |= TSPR_FLAGS_MDHACK;
shadowspr->cstat |= CSTAT_SPRITE_TRANS_FLIP;
}