From 0aeaed4207d9e5473e533476099be98f50a7fe02 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 29 Dec 2018 13:27:43 +0100 Subject: [PATCH] - use a TArray to store the sprite model hash to get rid of one atterm call. --- src/r_data/models/models.cpp | 23 ++++++----------------- src/r_data/models/models.h | 15 +-------------- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/src/r_data/models/models.cpp b/src/r_data/models/models.cpp index 6516ac5fda..e75d9d030c 100644 --- a/src/r_data/models/models.cpp +++ b/src/r_data/models/models.cpp @@ -53,7 +53,7 @@ EXTERN_CVAR (Bool, r_drawvoxels) extern TDeletingArray Voxels; extern TDeletingArray VoxelDefs; -DeletingModelArray Models; +TDeletingArray Models; void FModelRenderer::RenderModel(float x, float y, float z, FSpriteModelFrame *smf, AActor *actor, double ticFrac) { @@ -314,15 +314,9 @@ void FModel::DestroyVertexBuffer() } static TArray SpriteModelFrames; -static int * SpriteModelHash; +static TArray SpriteModelHash; //TArray StateModelFrames; -static void DeleteModelHash() -{ - if (SpriteModelHash != nullptr) delete [] SpriteModelHash; - SpriteModelHash = nullptr; -} - //=========================================================================== // // FindGFXFile @@ -489,13 +483,9 @@ static void ParseModelDefLump(int Lump); void InitModels() { - for (unsigned i = 0; i < Models.Size(); i++) - { - delete Models[i]; - } - Models.Clear(); + Models.DeleteAndClear(); SpriteModelFrames.Clear(); - DeleteModelHash(); + SpriteModelHash.Clear(); // First, create models for each voxel for (unsigned i = 0; i < Voxels.Size(); i++) @@ -548,9 +538,8 @@ void InitModels() } // create a hash table for quick access - SpriteModelHash = new int[SpriteModelFrames.Size ()]; - atterm(DeleteModelHash); - memset(SpriteModelHash, 0xff, SpriteModelFrames.Size () * sizeof(int)); + SpriteModelHash.Resize(SpriteModelFrames.Size ()); + memset(SpriteModelHash.Data(), 0xff, SpriteModelFrames.Size () * sizeof(int)); for (unsigned int i = 0; i < SpriteModelFrames.Size (); i++) { diff --git a/src/r_data/models/models.h b/src/r_data/models/models.h index 2f917e2285..6a286dc92b 100644 --- a/src/r_data/models/models.h +++ b/src/r_data/models/models.h @@ -462,21 +462,8 @@ FSpriteModelFrame * FindModelFrame(const PClass * ti, int sprite, int frame, boo bool IsHUDModelForPlayerAvailable(player_t * player); void FlushModels(); -class DeletingModelArray : public TArray -{ -public: - ~DeletingModelArray() - { - for (unsigned i = 0; i Models; // Check if circle potentially intersects with node AABB inline bool CheckBBoxCircle(float *bbox, float x, float y, float radiusSquared)