diff --git a/source/core/models/modeldata.cpp b/source/core/models/modeldata.cpp index d1f684d38..173d63113 100644 --- a/source/core/models/modeldata.cpp +++ b/source/core/models/modeldata.cpp @@ -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; } diff --git a/source/core/models/modeldata.h b/source/core/models/modeldata.h index 7a4725d4c..a617e8062 100644 --- a/source/core/models/modeldata.h +++ b/source/core/models/modeldata.h @@ -56,9 +56,9 @@ struct ModelManager TArray modelDescs; TMap 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)); } diff --git a/source/core/rendering/scene/hw_drawinfo.cpp b/source/core/rendering/scene/hw_drawinfo.cpp index b2e11a414..bd0df60ce 100644 --- a/source/core/rendering/scene/hw_drawinfo.cpp +++ b/source/core/rendering/scene/hw_drawinfo.cpp @@ -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; diff --git a/source/games/blood/src/animatesprite.cpp b/source/games/blood/src/animatesprite.cpp index e25cadd00..9c9e86136 100644 --- a/source/games/blood/src/animatesprite.cpp +++ b/source/games/blood/src/animatesprite.cpp @@ -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 diff --git a/source/games/duke/src/animatesprites.cpp b/source/games/duke/src/animatesprites.cpp index 3ef4cea94..e963c3b8a 100644 --- a/source/games/duke/src/animatesprites.cpp +++ b/source/games/duke/src/animatesprites.cpp @@ -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; }