OpenBarnyard
 
Loading...
Searching...
No Matches
TModelManager Class Reference

#include <TModelManager.h>

Classes

class  ModelNode
 

Static Public Member Functions

static void Initialise ()
 
static void Uninitialise ()
 
static ModelNodeCreateModel (const TCHAR *a_szFileName, TManagedModel &a_rModelRef, TTRB *a_pAssetTRB)
 

Static Public Attributes

static constexpr TUINT MAX_NUM_MODELS = 500
 
static ModelNodems_pEntries
 
static T2DList< ModelNodems_oUsedList
 
static T2DList< ModelNodems_oFreeList
 

Detailed Description

Definition at line 10 of file TModelManager.h.

Member Function Documentation

◆ CreateModel()

TModelManager::ModelNode * TModelManager::CreateModel ( const TCHAR * a_szFileName,
TManagedModel & a_rModelRef,
TTRB * a_pAssetTRB )
static

Definition at line 80 of file TModelManager.cpp.

81{
82 if ( ms_oFreeList.IsEmpty() )
83 {
84 TASSERT( TFALSE, "Couldn't create new model since the registry is all used" );
85 return TNULL;
86 }
87
88 TCHAR filepath[ 248 ];
89 auto iFileNameLen = TStringManager::String8Length( a_szFileName );
90 TStringManager::String8Copy( filepath, a_szFileName );
91
92 for ( TUINT i = 0; i < iFileNameLen; i++ )
93 {
94 if ( filepath[ i ] == '/' )
95 {
96 filepath[ i ] = '\\';
97 }
98 }
99
100 auto crc32 = TUtil::CRC32( TREINTERPRETCAST( TBYTE*, filepath ), iFileNameLen );
101
102 for ( auto it = ms_oUsedList.Begin(); it != ms_oUsedList.End(); ++it )
103 {
104 if ( it->GetCRC32() == crc32 )
105 {
106 a_rModelRef.m_pModel = it->GetModel();
107 it->IncRefCount();
108
109 return it;
110 }
111 }
112
113 auto pEntry = ms_oFreeList.PopBack();
114 ms_oUsedList.PushFront( pEntry );
115
116 const TCHAR* szFileName;
117 TUINT8 ui8NameLen = 0;
118
119 if ( !a_pAssetTRB || !TModel::GetSkeletonAssetSymbolName( filepath, szFileName, ui8NameLen, a_pAssetTRB ) )
120 {
121 a_pAssetTRB = TNULL;
122 szFileName = filepath;
123 ui8NameLen = -1;
124 }
125
126 auto pModel = TRenderInterface::GetSingleton()->CreateModel( szFileName, TTRUE, a_pAssetTRB, ui8NameLen );
127 pEntry->Create( crc32, pModel );
128 pEntry->IncRefCount();
129 a_rModelRef.m_pModel = pModel;
130
131 return pEntry;
132}
#define TASSERT(X,...)
Definition Defines.h:138
#define TREINTERPRETCAST(TYPE, VALUE)
Definition Defines.h:68
unsigned int TUINT
Definition Typedefs.h:8
char TCHAR
Definition Typedefs.h:20
uint8_t TUINT8
Definition Typedefs.h:17
#define TNULL
Definition Typedefs.h:23
#define TFALSE
Definition Typedefs.h:24
#define TTRUE
Definition Typedefs.h:25
uint8_t TBYTE
Definition Typedefs.h:19
static TBOOL GetSkeletonAssetSymbolName(const TCHAR *a_szFileName, const TCHAR *&a_rSymbolName, TUINT8 &a_rNameLen, TTRB *a_pTRB)
Definition TModel.cpp:217
virtual TBOOL Create(TTMD *a_pTMD, TBOOL a_bLoad)=0
static T2DList< ModelNode > ms_oUsedList
static T2DList< ModelNode > ms_oFreeList
virtual TModel * CreateModel(TTMD *a_pTMD, TBOOL a_bLoad)=0
static TFORCEINLINE TRenderInterface * GetSingleton()
Definition TSingleton.h:49
static TSIZE String8Length(const TCHAR *str)
static TCHAR * String8Copy(TCHAR *dst, const TCHAR *src, TSIZE size=-1)
static TUINT32 CRC32(void *buffer, TUINT32 len)
Definition TUtil.cpp:201

◆ Initialise()

void TModelManager::Initialise ( )
static

Definition at line 64 of file TModelManager.cpp.

65{
68}
static ModelNode * ms_pEntries
static constexpr TUINT MAX_NUM_MODELS

◆ Uninitialise()

void TModelManager::Uninitialise ( )
static

Definition at line 70 of file TModelManager.cpp.

71{
73 ms_oUsedList.Clear();
74 ms_oFreeList.Clear();
75
76 delete[] ms_pEntries;
78}

Member Data Documentation

◆ MAX_NUM_MODELS

TUINT TModelManager::MAX_NUM_MODELS = 500
staticconstexpr

Definition at line 64 of file TModelManager.h.

◆ ms_oFreeList

T2DList<ModelNode> TModelManager::ms_oFreeList
inlinestatic

Definition at line 75 of file TModelManager.h.

◆ ms_oUsedList

T2DList<ModelNode> TModelManager::ms_oUsedList
inlinestatic

Definition at line 74 of file TModelManager.h.

◆ ms_pEntries

ModelNode* TModelManager::ms_pEntries
inlinestatic

Definition at line 73 of file TModelManager.h.


The documentation for this class was generated from the following files: