/
ShapeLib.cpp
73 lines (60 loc) · 1.88 KB
/
ShapeLib.cpp
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* This file is part of TSRE5.
*
* TSRE5 - train sim game engine and MSTS/OR Editors.
* Copyright (C) 2016 Piotr Gadecki <pgadecki@gmail.com>
*
* Licensed under GNU General Public License 3.0 or later.
*
* See LICENSE.md or https://www.gnu.org/licenses/gpl.html
*/
#include "ShapeLib.h"
#include "Game.h"
#include <QDebug>
#include "SFile.h"
//int ShapeLib::jestshape;
//std::unordered_map<int, SFile*> ShapeLib::shape;
ShapeLib::ShapeLib() {
}
ShapeLib::ShapeLib(const ShapeLib& orig) {
}
ShapeLib::~ShapeLib() {
}
void ShapeLib::reset() {
jestshape = 0;
shape.clear();
}
void ShapeLib::delRef(int texx) {
/*if(!mtex.containsKey(texx)) return;
mtex.get(texx).ref--;
if(mtex.get(texx).ref<=0){
if(mtex.get(texx).glLoaded){
mtex.get(texx).delVBO(gl);
mtex.remove(texx);
}
}*/
}
void ShapeLib::addRef(int texx) {
//if(!mtex.containsKey(texx)) return;
//mtex.get(texx).ref++;
}
int ShapeLib::addShape(QString path){
return addShape(path, Game::root+"/routes/"+Game::route+"/textures");
}
int ShapeLib::addShape(QString path, QString texPath) {
QString pathid = path;//(path + "/" + name).toLower();
pathid.replace("\\", "/");
pathid.replace("//", "/");
//console.log(pathid);
for ( auto it = shape.begin(); it != shape.end(); ++it ){
if(it->second == NULL) continue;
if (((SFile*) it->second)->pathid.length() == pathid.length())
if (((SFile*) it->second)->pathid == pathid) {
((SFile*) it->second)->ref++;
return (int)it->first;
}
}
qDebug() << "Nowy " << jestshape << " shape: " << pathid;
shape[jestshape] = new SFile(pathid, path.split("/").last(), texPath);
shape[jestshape]->pathid = pathid;
return jestshape++;
}