- use a TArray to store the sprite model hash to get rid of one atterm call.

This commit is contained in:
Christoph Oelckers 2018-12-29 13:27:43 +01:00
parent 313ec62a5c
commit 0aeaed4207
2 changed files with 7 additions and 31 deletions

View file

@ -53,7 +53,7 @@ EXTERN_CVAR (Bool, r_drawvoxels)
extern TDeletingArray<FVoxel *> Voxels; extern TDeletingArray<FVoxel *> Voxels;
extern TDeletingArray<FVoxelDef *> VoxelDefs; extern TDeletingArray<FVoxelDef *> VoxelDefs;
DeletingModelArray Models; TDeletingArray<FModel*> Models;
void FModelRenderer::RenderModel(float x, float y, float z, FSpriteModelFrame *smf, AActor *actor, double ticFrac) void FModelRenderer::RenderModel(float x, float y, float z, FSpriteModelFrame *smf, AActor *actor, double ticFrac)
{ {
@ -314,15 +314,9 @@ void FModel::DestroyVertexBuffer()
} }
static TArray<FSpriteModelFrame> SpriteModelFrames; static TArray<FSpriteModelFrame> SpriteModelFrames;
static int * SpriteModelHash; static TArray<int> SpriteModelHash;
//TArray<FStateModelFrame> StateModelFrames; //TArray<FStateModelFrame> StateModelFrames;
static void DeleteModelHash()
{
if (SpriteModelHash != nullptr) delete [] SpriteModelHash;
SpriteModelHash = nullptr;
}
//=========================================================================== //===========================================================================
// //
// FindGFXFile // FindGFXFile
@ -489,13 +483,9 @@ static void ParseModelDefLump(int Lump);
void InitModels() void InitModels()
{ {
for (unsigned i = 0; i < Models.Size(); i++) Models.DeleteAndClear();
{
delete Models[i];
}
Models.Clear();
SpriteModelFrames.Clear(); SpriteModelFrames.Clear();
DeleteModelHash(); SpriteModelHash.Clear();
// First, create models for each voxel // First, create models for each voxel
for (unsigned i = 0; i < Voxels.Size(); i++) for (unsigned i = 0; i < Voxels.Size(); i++)
@ -548,9 +538,8 @@ void InitModels()
} }
// create a hash table for quick access // create a hash table for quick access
SpriteModelHash = new int[SpriteModelFrames.Size ()]; SpriteModelHash.Resize(SpriteModelFrames.Size ());
atterm(DeleteModelHash); memset(SpriteModelHash.Data(), 0xff, SpriteModelFrames.Size () * sizeof(int));
memset(SpriteModelHash, 0xff, SpriteModelFrames.Size () * sizeof(int));
for (unsigned int i = 0; i < SpriteModelFrames.Size (); i++) for (unsigned int i = 0; i < SpriteModelFrames.Size (); i++)
{ {

View file

@ -462,21 +462,8 @@ FSpriteModelFrame * FindModelFrame(const PClass * ti, int sprite, int frame, boo
bool IsHUDModelForPlayerAvailable(player_t * player); bool IsHUDModelForPlayerAvailable(player_t * player);
void FlushModels(); void FlushModels();
class DeletingModelArray : public TArray<FModel *>
{
public:
~DeletingModelArray() extern TDeletingArray<FModel*> Models;
{
for (unsigned i = 0; i<Size(); i++)
{
delete (*this)[i];
}
}
};
extern DeletingModelArray Models;
// Check if circle potentially intersects with node AABB // Check if circle potentially intersects with node AABB
inline bool CheckBBoxCircle(float *bbox, float x, float y, float radiusSquared) inline bool CheckBBoxCircle(float *bbox, float x, float y, float radiusSquared)