-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModelManager.cpp
More file actions
50 lines (32 loc) · 903 Bytes
/
ModelManager.cpp
File metadata and controls
50 lines (32 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "stdafx.h"
#include "ModelManager.h"
#include "LogManager.h"
ModelManager ModelManager::m_sInstance;
ModelManager::ModelManager() {
}
ModelManager* ModelManager::instance() {
return &m_sInstance;
}
Model* ModelManager::getModel(std::string filepath, unsigned int loadFlags) {
ModelMap::iterator found = m_xModelCache.find(filepath);
Model* ret;
if (found == m_xModelCache.end()) {
ret = new Model(filepath, loadFlags);
m_xModelCache[filepath] = ret;
} else {
ret = found->second;
}
return ret;
}
void ModelManager::clearCache() {
/* Loops the mesh table and free data held by the meshes */
for(ModelMap::iterator it = m_xModelCache.begin(); it != m_xModelCache.end(); ++it) {
//std::string meshName = it->first;
delete it->second;
}
m_xModelCache.clear();
Log::Writeln("ModelManager cache cleared");
}
ModelManager::~ModelManager() {
clearCache();
}