fixed the memory garbage problem
This commit is contained in:
@@ -126,10 +126,10 @@ void OpenGLController::deleteVectors()
|
||||
|
||||
while (!segmCuror->meshIndices.empty())
|
||||
{
|
||||
std::vector<std::uint32_t>* meshCursor = segmCuror->meshIndices.back();
|
||||
meshCursor->clear();
|
||||
while (!segmCuror->meshIndices.back().empty())
|
||||
segmCuror->meshIndices.back().pop_back();
|
||||
|
||||
segmCuror->meshIndices.pop_back();
|
||||
delete meshCursor;
|
||||
}
|
||||
|
||||
delete segmCuror;
|
||||
@@ -350,7 +350,7 @@ void OpenGLController::updateScene()
|
||||
// calculate the number of vertex
|
||||
unsigned int vertexCount(0);
|
||||
for (auto& it : segIt->meshIndices)
|
||||
vertexCount += (it->size() - 2) * 3;
|
||||
vertexCount += (it.size() - 2) * 3;
|
||||
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, instanceOffset, vertexCount);
|
||||
@@ -393,10 +393,10 @@ void OpenGLController::loadMsh(const char * path)
|
||||
{
|
||||
for (auto& mshIt : segIt->meshIndices) // for every polygon
|
||||
{
|
||||
if (mshIt->size() >= 3) // multipoly
|
||||
if (mshIt.size() >= 3) // multipoly
|
||||
{
|
||||
// for every triangle of the multi polygon
|
||||
for (unsigned int tri = 0; tri < mshIt->size() - 2; tri++)
|
||||
for (unsigned int tri = 0; tri < mshIt.size() - 2; tri++)
|
||||
{
|
||||
// for every edge of the triangle
|
||||
for (int triEdge = 0; triEdge < 3; triEdge++)
|
||||
@@ -404,7 +404,7 @@ void OpenGLController::loadMsh(const char * path)
|
||||
Vertex tempVertex;
|
||||
// every edge has 3 coordinates
|
||||
for (int j = 0; j < 3; j++)
|
||||
tempVertex.position[j] = (GLfloat)segIt->vertex[(*mshIt)[tri + triEdge - ((tri % 2) * (triEdge - 1) * 2)] * 3 + j];
|
||||
tempVertex.position[j] = (GLfloat)segIt->vertex[mshIt[tri + triEdge - ((tri % 2) * (triEdge - 1) * 2)] * 3 + j];
|
||||
|
||||
// and 2 UV
|
||||
if (segIt->uv == NULL)
|
||||
@@ -415,7 +415,7 @@ void OpenGLController::loadMsh(const char * path)
|
||||
else
|
||||
{
|
||||
for (int j = 0; j < 2; j++)
|
||||
tempVertex.uv[j] = (GLfloat)segIt->uv[(*mshIt)[tri + triEdge - ((tri % 2) * (triEdge - 1) * 2)] * 2 + j];
|
||||
tempVertex.uv[j] = (GLfloat)segIt->uv[mshIt[tri + triEdge - ((tri % 2) * (triEdge - 1) * 2)] * 2 + j];
|
||||
}
|
||||
tempBufferData.push_back(tempVertex);
|
||||
}
|
||||
@@ -441,6 +441,8 @@ void OpenGLController::loadMsh(const char * path)
|
||||
);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
tempBufferData.clear();
|
||||
|
||||
|
||||
// get textures path
|
||||
std::string tempPath = path;
|
||||
|
||||
Reference in New Issue
Block a user