Skip to content

Commit

Permalink
- use texture IDs in the model interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Mar 27, 2023
1 parent 7a96478 commit 6c0d054
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
5 changes: 3 additions & 2 deletions source/core/models/modeldata.cpp
Expand Up @@ -5,6 +5,7 @@
#include "hw_voxels.h"
#include "gamefuncs.h"
#include "tiletexture.h"
#include "buildtiles.h"

#include "build.h"

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 4 additions & 4 deletions source/core/models/modeldata.h
Expand Up @@ -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
Expand All @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion source/core/rendering/scene/hw_drawinfo.cpp
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion source/games/blood/src/animatesprite.cpp
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions source/games/duke/src/animatesprites.cpp
Expand Up @@ -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;
}
Expand Down

0 comments on commit 6c0d054

Please sign in to comment.