fixed the memory garbage problem
This commit is contained in:
@@ -434,7 +434,7 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempSize), sizeof(tempSize));
|
||||
|
||||
int highBitCount(0);
|
||||
std::vector<uint32_t>* tempPoly = new std::vector<uint32_t>;
|
||||
std::vector<uint32_t> tempPoly; // = new std::vector<uint32_t>;
|
||||
|
||||
for (unsigned int i = 0; i < tempSize; i++)
|
||||
{
|
||||
@@ -449,7 +449,7 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
|
||||
tempValue = (std::uint16_t(tempValue << 1) >> 1);
|
||||
}
|
||||
|
||||
tempPoly->push_back((std::uint32_t)tempValue);
|
||||
tempPoly.push_back((std::uint32_t)tempValue);
|
||||
|
||||
// new Polygon found
|
||||
if (highBitCount == 2)
|
||||
@@ -461,18 +461,20 @@ void Object::analyseSegmChunks(Modl * dataDestination, std::list<ChunkHeader*>&
|
||||
std::uint32_t saveData[2];
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
saveData[i] = tempPoly->back();
|
||||
tempPoly->pop_back();
|
||||
saveData[i] = tempPoly.back();
|
||||
tempPoly.pop_back();
|
||||
}
|
||||
|
||||
// ..and save them in the new vector
|
||||
std::vector<uint32_t>* newPointer = new std::vector<uint32_t>;
|
||||
tempData->meshIndices.push_back(tempPoly);
|
||||
|
||||
tempPoly.clear();
|
||||
for (int i = 1; i >= 0; i--)
|
||||
newPointer->push_back(saveData[i]);
|
||||
tempPoly.push_back(saveData[i]);
|
||||
|
||||
// save the old vector and set the pointer to the new one
|
||||
tempData->meshIndices.push_back(tempPoly);
|
||||
tempPoly = newPointer;
|
||||
//tempData->meshIndices.push_back(tempPoly);
|
||||
//tempPoly = newPointer;
|
||||
} // if high bit set
|
||||
|
||||
} // for all values
|
||||
@@ -542,19 +544,19 @@ void Object::analyseClthChunks(Modl * dataDestination, std::list<ChunkHeader*>&
|
||||
fsMesh.seekg((*it)->position);
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempSize), sizeof(tempSize));
|
||||
|
||||
std::vector<uint32_t>* tempPoly;
|
||||
std::vector<uint32_t> tempPoly;
|
||||
|
||||
// for every triangle..
|
||||
for (unsigned int i = 0; i < tempSize; i += 3)
|
||||
{
|
||||
tempPoly = new std::vector<uint32_t>;
|
||||
tempPoly.clear();
|
||||
|
||||
// ..get the 3 indices and save them
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
std::uint32_t tempValue;
|
||||
fsMesh.read(reinterpret_cast<char*>(&tempValue), sizeof(std::uint32_t));
|
||||
tempPoly->push_back(tempValue);
|
||||
tempPoly.push_back(tempValue);
|
||||
}
|
||||
tempData->meshIndices.push_back(tempPoly);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user