removed unused files,

removed unused functions,
removed unused variables,
reduced dynamic stack memory (there was too much allocated),
moved some code around into better place,
implemented destructor (there is still a std::_face_node left on the stack when the program is done),
This commit is contained in:
Anakin
2016-10-31 16:19:12 +01:00
parent ea07ead94f
commit a875820f48
8 changed files with 44 additions and 221 deletions

View File

@@ -61,7 +61,11 @@ Object::Object(const char* path)
Object::~Object()
{
//delete Chunk list;
// clear texture list
vTextures.clear();
// clear Model list (don't delete the elements)
vModls.clear();
}
@@ -464,7 +468,7 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
fsMesh.seekg((*it)->position);
fsMesh.read(reinterpret_cast<char*>(&dataDestination->meshSize), sizeof(dataDestination->meshSize));
dataDestination->mesh = new std::uint32_t[dataDestination->meshSize * 3];
dataDestination->mesh = new std::uint32_t[dataDestination->meshSize];
for (unsigned int i = 0; i < dataDestination->meshSize; i += 3)
{
@@ -542,12 +546,8 @@ void Object::readVertex(Modl* dataDestination, std::streampos position)
dataDestination->vertex = new float[tempSize * 3];
for (unsigned int i = 0; i < tempSize * 3; i += 3)
{
for (unsigned int i = 0; i < tempSize * 3; i++)
fsMesh.read(reinterpret_cast<char*>(&dataDestination->vertex[i]), sizeof(float));
fsMesh.read(reinterpret_cast<char*>(&dataDestination->vertex[i + 1]), sizeof(float));
fsMesh.read(reinterpret_cast<char*>(&dataDestination->vertex[i + 2]), sizeof(float));
}
}
void Object::readUV(Modl* dataDestination, std::streampos position)
@@ -558,92 +558,14 @@ void Object::readUV(Modl* dataDestination, std::streampos position)
dataDestination->uv = new float[tempSize * 2];
for (unsigned int i = 0; i < tempSize * 2; i += 2)
{
for (unsigned int i = 0; i < tempSize * 2; i++)
fsMesh.read(reinterpret_cast<char*>(&dataDestination->uv[i]), sizeof(float));
fsMesh.read(reinterpret_cast<char*>(&dataDestination->uv[i + 1]), sizeof(float));
}
}
/////////////////////////////////////////////////////////////////////////
// public getter
std::vector<GLfloat> Object::getVertex() const
{
std::vector<GLfloat> tempData;
for (std::vector<Modl*>::const_iterator it = vModls.begin(); it != vModls.end(); it++)
{
if ((*it)->renderFlags == 1)
continue;
for (unsigned int i = 0; i < (*it)->meshSize; i++)
{
tempData.push_back((GLfloat)(*it)->vertex[(*it)->mesh[i] * 3]);
tempData.push_back((GLfloat)(*it)->vertex[(*it)->mesh[i] * 3 + 1]);
tempData.push_back((GLfloat)(*it)->vertex[(*it)->mesh[i] * 3 + 2]);
}
}
return tempData;
}
std::vector<GLfloat> Object::getUV() const
{
std::vector<GLfloat> tempData;
for (std::vector<Modl*>::const_iterator it = vModls.begin(); it != vModls.end(); it++)
{
if ((*it)->renderFlags == 1)
continue;
if ((*it)->uv == NULL)
{
for (unsigned int i = 0; i < (*it)->meshSize; i++)
tempData.push_back(1.0);
continue;
}
for (unsigned int i = 0; i < (*it)->meshSize; i++)
{
tempData.push_back((GLfloat)(*it)->uv[(*it)->mesh[i] * 2]);
tempData.push_back((GLfloat)(*it)->uv[(*it)->mesh[i] * 2 + 1]);
}
}
return tempData;
}
std::uint32_t Object::getSize() const
{
std::uint32_t tempData(0);
for (std::vector<Modl*>::const_iterator it = vModls.begin(); it != vModls.end(); it++)
{
if ((*it)->renderFlags == 1)
continue;
tempData += (*it)->meshSize;
}
return tempData;
}
std::list<std::string> Object::getTexture() const
{
std::list<std::string> tempData;
for (std::vector<Modl*>::const_iterator it = vModls.begin(); it != vModls.end(); it++)
{
if ((*it)->renderFlags == 1)
continue;
tempData.push_back((*it)->texture);
}
return tempData;
}
std::vector<Modl*> Object::getModels() const
{
return vModls;